Skip to content

Commit

Permalink
Fix jest tests for ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck committed Jul 22, 2023
1 parent 3a3dce8 commit bd23aaf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
41 changes: 21 additions & 20 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
module.exports = {
rootDir: './',
moduleFileExtensions: ['ts', 'js'],
testMatch: ['**/test/**/*.test.ts', '**/test/tests.ts'],
coverageProvider: 'v8',
coveragePathIgnorePatterns: [
'/node_modules/',
'./jest.config.js',
'./test',
/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
rootDir: "./",
moduleFileExtensions: ["ts", "js"],
testMatch: ["**/test/**/*.test.ts", "**/test/tests.ts"],
coverageProvider: "v8",
coveragePathIgnorePatterns: ["/node_modules/", "./jest.config.js", "./test"],
extensionsToTreatAsEsm: ['.ts'],
reporters: [
"default",
["jest-junit", { outputDirectory: "test-results/jest" }],
],
coverageReporters: ["lcov", "text", "text-summary"],
setupFiles: [],
preset: 'ts-jest/presets/default-esm',
transform: {
"^.+\\.ts?$": [
"ts-jest",
{ useESM: true, tsconfig: "./tsconfig.test.json" },
],
reporters: [
'default',
['jest-junit', { outputDirectory: 'test-results/jest' }]
],
coverageReporters: ['lcov', 'text', 'text-summary'],
setupFiles: [],
preset: 'ts-jest',
transform: {
'^.+\\.ts?$': ['ts-jest', {tsconfig: './tsconfig.test.json'}]
},
};
},
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"build": "rimraf dist && rollup -m -c --environment NODE_ENV:production",
"postbuild": "echo '{\"type\": \"commonjs\"}'> dist/cjs/package.json",
"test": "npm run test:node && npm run test:browser",
"test:node": "jest --coverage",
"test:browser": "jest --coverage --testEnvironment=jsdom"
"test:node": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --coverage",
"test:browser": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --coverage --testEnvironment=jsdom"
},
"author": "Jose F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)",
"contributors": [
Expand Down

0 comments on commit bd23aaf

Please sign in to comment.