Hi, thanks for advance.
My project has babel 6.x . So i installed [email protected] and [email protected]. Because according to docs babel 6 is required jest 23.x or jest 24.x with babel-jest 23.x.
But when i run test code with jest, i got fail with error message like this
Plugin/Preset files are not allowed to export objects, only functions. In C:\workspaces\lbd2\lbd2_vue\node_modules\babel-preset-stage-2\lib\index.js
My question is when i use babel 6, is it right to install jest 24.x with babel-jest 23.x? Or is there something that i misunderstand?
Please follow the templates (particularly include a reproduction). Happy to reopen once a reproduction is added
The issue can be reproduced if Babel setup uses some presets (I suppose they're kinda "old-style" or something like that):
$ cat package.json
{
"name": "jest-reproduction",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.26.3",
"babel-jest": "^23.6.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-1": "^6.24.1",
"jest": "^24.5.0",
"react-hot-loader": "^4.8.0"
}
}
$ cat .babelrc
{
"presets": ["es2015", "react", "stage-1"]
}
Any of the presets in the example above (and stage-2 as we can see from the original issue description) produce the error:
$ npm jest
Plugin/Preset files are not allowed to export objects, only functions. In \jest-reproduction\node_modules\babel-preset-es2015\lib\index.js
@SimenB I've created a reproduction repo, can you please re-open? Thanks!
https://github.com/jochakovsky/Jest-24-Babel-6-preset-bug - just need to clone, run yarn install and yarn run test.
One workaround I've found is to add "resolutions": {"babel-jest": "23.6.0"} to package.json, though this is hacky and yarn-specific.
Most helpful comment
@SimenB I've created a reproduction repo, can you please re-open? Thanks!
https://github.com/jochakovsky/Jest-24-Babel-6-preset-bug - just need to clone, run
yarn installandyarn run test.One workaround I've found is to add
"resolutions": {"babel-jest": "23.6.0"}to package.json, though this is hacky and yarn-specific.