New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
babel-jest fails on dynamic babel.config.js due to old "babel-core" dependency #6916
Comments
I'd assume the fix here is to drop The diff for my changes can be seen here for anyone interested. I also changed the caching logic to use |
I'm having the same issue where - Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details: |
I have the same issue and found an ugly workaround for now:
Put this into 👍 on adding support for @babel/core 7 |
Closing as duplicate of #6913, but feel free to chime in there with your reproduction case. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
Babel 7 added support for dynamic configuration, however, because
babel-jest
is dependant onbabel-core
, it's using the wrong version of babel for loading options and running transformations. Babel 7 uses@babel/core@^7.0.0
which is an entirely different module.As such, it doesn't load the user's
@babel/core
but instead loads the one provided byjest-config
transiently which does not pick up the newbabel.config.js
format introduced in 7.Dynamic Configuration Docs
To Reproduce
Run jest using babel-jest in a project with:
babel.config.js
(i.e. a module which resolves to a function which returns the babel options).It will error.
Test output
Expected behavior
I expected jest to run tests using the dynamic babel configuration without issue.
Link to repl or repo (highly encouraged)
I can try setting one up if needed.
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: