Skip to content

Commit

Permalink
test: run Jest tests in native ESM mode
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Dec 2, 2023
1 parent 8db4a15 commit 077e6bc
Show file tree
Hide file tree
Showing 54 changed files with 614 additions and 488 deletions.
3 changes: 3 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [["@babel/preset-env", { "modules": "cjs", "targets": { "node": "current" } }]]
}
2 changes: 2 additions & 0 deletions .changeset/wicked-actors-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
3 changes: 0 additions & 3 deletions babel.config.cjs

This file was deleted.

17 changes: 7 additions & 10 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
const config = {
collectCoverageFrom: [
'lib/**/*.js',
// Avoid ESM import.meta parse error.
// (Can't measure coverage anyway, it's always mocked)
/**
* Instanbul uses babel to parse coverage data,
* so `import.meta` is not available
*/
'!lib/resolveConfig.js',
],
moduleDirectories: ['node_modules'],
prettierPath: null,
setupFiles: ['./testSetup.js'],
snapshotSerializers: ['jest-snapshot-serializer-ansi'],
setupFiles: ['./test/testSetup.js'],
snapshotSerializers: ['./test/serializer.cjs'],
testEnvironment: 'node',
transform: {
'\\.[jt]sx?$': 'babel-jest',
'\\.mjs$': 'babel-jest',
},
/** Also transform ESM packages in `node_modules` */
transformIgnorePatterns: [],
transform: {},
}

export default config
Loading

0 comments on commit 077e6bc

Please sign in to comment.