es-babel-jest
v1.0.0
Published
esbuild + babel-jest default preprocessor for Jest
Downloads
9
Readme
es-babel-jest
Directly forked from https://github.com/ambar/es-jest (thanks!), es-babel-jest is a ESM/React/TypeScript preprocessor for Jest, powered by esbuild. It will transform any ES modules into valid CJS (CommonJS) modules, to make your tests written in ES modules works out of the box with jest. It also pipe babel-jest transforms once preprocessed with esbuild, to allow jest helpers "hoisting" and all babel-jest default behavior.
Install
npm install es-babel-jest --save-dev
Usage
Add preset to Jest config:
{
"jest": {
"preset": "es-babel-jest"
}
}
// alternatively, specifying the files to transform:
{
"jest": {
"transform": {
"\\.[jt]sx?$": "es-babel-jest"
},
}
}
Writes your test with ES modules:
import path from 'path'
test('parses extname', () => {
expect(path.extname('foo.md')).toBe('.md')
})
Happy testing!