babel-jest-modules
v0.0.2
Published
Babel jest transformer compatible with es6 modules
Downloads
127
Maintainers
Readme
babel-jest-modules
When "type": "module"
is present in a package.json
node assumes every .js
files in that directory tree is an ES module, then it must be imported with es6 import
.
While babel configuration lets you use .babelrc.cjs
/babel.config.cjs
or a "babel" key in your package.json
, babel-jest seems to read exclusively babel.config.js
.
This package should let you use jest and ES modules with the following setup:
yarn add --dev jest @babel/core @babel/preset-env babel-jest-modules
package.json
{
"type": "module",
"jest": {
"transform": {
"^.*\\.js$": "babel-jest-modules"
}
},
"babel": {
"presets": [
"@babel/preset-env"
]
}
}