TypeError:Object.values不是一个函数 - 如何在jest中正确填充babel-preset-env?

时间:2017-10-12 15:53:11

标签: jestjs

升级到Jest v20后出现以下错误:由于内存泄漏,他们删除了自动Private Sub ClearControls() Dim ctrl As MSForms.Control For Each ctrl In Me.Controls Select Case True Case TypeOf ctrl Is MSForms.TextBox Dim txtBox As MSForms.TextBox Set txtBox = ctrl txtBox.Text = vbNullString Case TypeOf ctrl Is MSForms.ComboBox Dim cmbBox As MSForms.ComboBox Set cmbBox = ctrl cmbBox.ListIndex = -1 Case TypeOf ctrl Is MSForms.OptionButton Dim optBtn As MSForms.OptionButton Set optBtn = ctrl optBtn.Value = False Case TypeOf ctrl Is MSForms.CheckBox Dim chkBox As MSForms.CheckBox Set chkBox = ctrl chkBox.Value = False Case TypeOf ctrl Is MSForms.ListBox Dim lstBox As MSForms.ListBox Set lstBox = ctrl Dim i As Long For i = 0 To lstBox.ListCount - 1 lstBox.Selected(i) = False Next Case TypeOf ctrl Is RefEdit.RefEdit Dim refEditCtrl As RefEdit.RefEdit Set refEditCtrl = ctrl refEditCtrl.Value = vbNullString End Select Next End Sub

babel-polyfill

我意识到我现在需要自己填充这个,我正在使用TypeError: Object.values is not a function并拥有以下babel-preset-env文件:

.babelrc

我可以看到调试输出中正在填充 "env": { "development": { "plugins": ["transform-react-jsx-source"] }, "test": { "presets": [ "react", "stage-3", ["env", { "targets": { "browsers": [ "firefox >= 36", "chrome >= 38", "opera >= 25", "safari >= 9", "ios >= 9" ], "node": "6.11.4" }, "useBuiltIns": "usage", "include": ["es7.object.values"], "debug": true }], "jest" ], "plugins": [ "transform-class-properties" ], } }

es7.object.values

但我仍然收到错误消息,帮助!

2 个答案:

答案 0 :(得分:2)

有些选项是:

  1. 将节点版本添加到支持Object.values的那个(其中 似乎7.0来自this answer),
  2. polyfill 使用babel-polyfillimport 'babel-polyfill'文件中的setupTests.js)。

答案 1 :(得分:0)

就我而言,原因是Node版本。 我刚刚将node 6更新为node 7,并已解决。