Repository navigation
Expand file tree
/
Copy pathjest.config.cjs
More file actions
57 lines (56 loc) · 2.03 KB
/
Copy pathjest.config.cjs
File metadata and controls
57 lines (56 loc) · 2.03 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// UTC by default for deterministic date goldens; JEST_TZ runs the local-day tests in another zone.
process.env.TZ = process.env.JEST_TZ || 'UTC';
/** @type {import('ts-jest').JestConfigWithTsJest} */
// CommonJS config (.cjs) because package.json sets "type": "module";
// a plain jest.config.js with module.exports fails to load under ESM.
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
// TS-only test runner. Vue SFC component tests are intentionally not run
// here (see TM-8825): the only such test was a no-op vue-cli scaffold stub
// and was removed rather than wiring up vue-jest/babel for zero assertions.
testMatch: ['**/__tests__/**/*.test.ts', '**/?(*.)+(spec|test).ts'],
moduleNameMapper: {
'^\\./messageCatalog$': '<rootDir>/src/i18n/messageCatalog.node.ts',
// jsdom resolves the "browser" export (ESM); pin the CommonJS builds.
'^vue-i18n$': '<rootDir>/node_modules/vue-i18n/dist/vue-i18n.cjs',
'^@intlify/(core-base|shared|message-compiler)$':
'<rootDir>/node_modules/@intlify/$1/dist/$1.cjs',
'^@/(.*)$': '<rootDir>/src/$1',
},
// marked ships ESM only and jest runs CommonJS here, so it is compiled like
// the rest of the sources instead of being skipped as a node_modules file.
// plugin-sdk/testing is already plain CommonJS (see plugin-sdk/testing/sync-prelude.mjs)
// and needs no further transform.
transformIgnorePatterns: [
'/node_modules/(?!(marked|d3-force|d3-quadtree|d3-dispatch|d3-timer)/)',
'/plugin-sdk/testing/',
],
transform: {
'^.+\\.m?js$': [
'ts-jest',
{
tsconfig: {
allowJs: true,
target: 'ES2020',
module: 'CommonJS',
esModuleInterop: true,
},
},
],
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: {
isolatedModules: true,
target: 'ES2020',
module: 'CommonJS',
lib: ['ES2021', 'DOM'],
esModuleInterop: true,
baseUrl: '.',
paths: { '@/*': ['./src/*'] },
},
},
],
},
};