I get the following error after upgrading to Jest v20 where they removed the automatic babel-polyfill
due to memory leaks:
TypeError: Object.values is not a function
I realize I need to polyfill this on my own now, I am using babel-preset-env
and have the following .babelrc
file:
"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"
],
}
}
I can see that es7.object.values
is being polyfilled in the debug output:
Using polyfills:
...
es7.object.values {"chrome":"38","firefox":"36","ios":"9","safari":"9","node":"6.11.4"}
But I am still getting the error message, help!
Some of the options are:
Object.values
(which
seems to be 7.0
judging from this answer),babel-polyfill
(via import 'babel-polyfill'
in setupTests.js
file).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With