Skip to content

Commit

Permalink
chore: refactor Jest configuration to allow verbatimModuleSyntax (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas authored Aug 24, 2023
1 parent bd1a230 commit ceb328a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JestConfigWithTsJest } from 'ts-jest';
import type { JestConfigWithTsJest } from 'ts-jest';

const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest/presets/default-esm', // or other ESM presets
Expand All @@ -9,4 +9,4 @@ const jestConfig: JestConfigWithTsJest = {
projects: ['<rootDir>/packages/plainjs', '<rootDir>/packages/node', '<rootDir>/packages/whatwg'],
};

export default jestConfig;
export = jestConfig;
4 changes: 2 additions & 2 deletions packages/node/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JestConfigWithTsJest } from 'ts-jest';
import type { JestConfigWithTsJest } from 'ts-jest';

const jestConfig: JestConfigWithTsJest = {
extensionsToTreatAsEsm: ['.ts'],
Expand All @@ -15,4 +15,4 @@ const jestConfig: JestConfigWithTsJest = {
setupFilesAfterEnv: ['<rootDir>/test/utils/setup.ts']
}

export default jestConfig;
export = jestConfig;
12 changes: 9 additions & 3 deletions packages/plainjs/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { JestConfigWithTsJest } from 'ts-jest';
import type { JestConfigWithTsJest } from 'ts-jest';

const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest/presets/default-esm', // or other ESM presets
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1' },
transform: {
'^.+\\.m?[t]sx?$': ['ts-jest', {
isolatedModules: true,
useESM: true
}],
},
testEnvironment: 'node',
testMatch: ['<rootDir>/**/test/*.ts', '<rootDir>/**/test/types/*.ts'],
collectCoverageFrom: ['src/**'],
};

export default jestConfig;
export = jestConfig;
4 changes: 2 additions & 2 deletions packages/whatwg/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JestConfigWithTsJest } from 'ts-jest';
import type { JestConfigWithTsJest } from 'ts-jest';

const jestConfig: JestConfigWithTsJest = {
extensionsToTreatAsEsm: ['.ts'],
Expand All @@ -15,4 +15,4 @@ const jestConfig: JestConfigWithTsJest = {
setupFilesAfterEnv: ['<rootDir>/test/utils/setup.ts']
}

export default jestConfig;
export = jestConfig;
15 changes: 4 additions & 11 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"ts-node": {
"moduleTypes": {
"jest.config.ts": "cjs"
}
},
"compilerOptions": {
/* Language and Environment */
"target": "es6",
Expand All @@ -18,7 +13,7 @@
/* Interop Constraints */
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
// "verbatimModuleSyntax": true,
"verbatimModuleSyntax": true,
/* Type Checking */
"allowUnreachableCode": false,
// "exactOptionalPropertyTypes": true,
Expand All @@ -30,9 +25,7 @@
"preserveConstEnums": true,
"strict": true,
/* Projects */
"incremental": true,
"incremental": true
},
"include": [
"src/**/*.ts"
]
}
"include": ["**/src/**/*.ts"]
}

0 comments on commit ceb328a

Please sign in to comment.