-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.js
37 lines (35 loc) · 1.13 KB
/
jest.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const url = `file://${__dirname}/packages/configuration/paths.ts`
const configureMetaUrl = {
diagnostics: { ignoreCodes: [1343] },
astTransformers: {
before: [
{
path: 'ts-jest-mock-import-meta',
options: { metaObjectReplacement: { url } },
},
],
},
}
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest/presets/default-esm',
// preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
// https://www.npmjs.com/package/ts-jest-mock-import-meta
'^.+\\.tsx?$': ['ts-jest', { ...configureMetaUrl, useESM: true }],
// https://stackoverflow.com/a/61785012
'node_modules/chalk/.+\\.(j|t)sx?$': 'ts-jest',
},
transformIgnorePatterns: ['node_modules/(?!chalk)'],
extensionsToTreatAsEsm: ['.ts'],
// exclude node_modules and dist folder from tests
modulePathIgnorePatterns: ['<rootDir>/.*/node_modules/', '<rootDir>/.*/dist/'],
// code coverage reports
collectCoverage: true,
coverageDirectory: '<rootDir>/coverage/',
coverageReporters: ['json', 'lcov', 'text', 'clover', 'html'],
}