After upgrading from Jest 23.6.0 to 24.0.0 I'm getting this error: Plugin/Preset files are not allowed to export objects, only functions.
This is caused by this commit: https://github.com/facebook/jest/pull/7203/files which documents the breaking change.
For those of us using require
, it's not clear on what change we need to make in our repos to fix this.
There are a number of similar questions here on Stack Overflow but none of them have lead me to the solution yet...
Recently I had the same issue working with Jest 24.0.0. This is what I did to have it running.
First I installed the dependencies as they explain in the docs, but I used npm insted of yarn.
npm install --save-dev babel-jest @babel/core @babel/preset-env
Then I had to add a file called babel.config.js with this content:
// babel.config.js
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
};
And then it started to work correclty. I hope this can help.
presets[0][1] must be an object. ================ important
{
"presets": [
[
"env",
{
"targets": {
"node": "current"
}
},
"react"
]
],
"plugins": [
"transform-object-rest-spread",
"transform-class-properties"
]
}
<!-- end snippet -->
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