Skip to content

Commit

Permalink
Jest transform workaround for ESM-only packages
Browse files Browse the repository at this point in the history
Enables Babel transform for ESM-only packages (to CommonJS) until Jest supports ESM https://jestjs.io/docs/ecmascript-modules
  • Loading branch information
colinrotherham committed Nov 8, 2022
1 parent fcfc213 commit 77ee513
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,26 @@ const config = {
testEnvironment: './config/jest/environment/node.mjs',
transform: {
'^.+\\.m?js$': ['babel-jest', { rootMode: 'upward' }]
}
},

// Enable Babel transform for ESM-only packages to CommonJS
// until Jest supports ESM https://jestjs.io/docs/ecmascript-modules
transformIgnorePatterns: [
`/node_modules/?!(${[
'del',
'slash',
// Including child dependencies
'aggregate-error',
'clean-stack',
'escape-string-regexp',
'globby',
'indent-string',
'is-path-cwd',
'is-path-inside',
'p-map'
].join('|')})`
]
}

module.exports = {
Expand Down

0 comments on commit 77ee513

Please sign in to comment.