Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneLem committed Jul 27, 2022
1 parent c25eb85 commit e2d4a49
Show file tree
Hide file tree
Showing 4 changed files with 266 additions and 2 deletions.
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ module.exports = {
// testRunner: "jest-circus/runner",

// A map from regular expressions to paths to transformers
// transform: undefined,
transform: {
'.js$': './jest/esm-transformer.js',
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
Expand Down
13 changes: 13 additions & 0 deletions jest/esm-transformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const babel = require('@babel/core')

module.exports = {
process(src) {
const transform = babel.transform(src, {
babelrc: false,
compact: false,
plugins: [require.resolve('@babel/plugin-transform-modules-commonjs')],
})

return transform
},
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"test": "yarn node --experimental-vm-modules $(yarn bin jest)"
},
"devDependencies": {
"@babel/core": "7.18.9",
"@babel/plugin-transform-modules-commonjs": "7.18.6",
"jest": "28.0.0",
"jest-environment-jsdom": "28.0.0",
"prettier": "2.5.1"
Expand Down
Loading

0 comments on commit e2d4a49

Please sign in to comment.