-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathjest.preset.js
More file actions
50 lines (48 loc) · 1.78 KB
/
Copy pathjest.preset.js
File metadata and controls
50 lines (48 loc) · 1.78 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
// Resolve via the @nx/jest exports map. A plain Node require (no --conditions)
// skips the @nx/nx-source condition, so this lands on the built dist/preset.js
// rather than the local TypeScript source.
const nxPreset = require('@nx/jest/preset').default;
const path = require('path');
// SWC resolves bare plugin names by walking node_modules upward from cwd.
// Tests that chdir into temp dirs would fail resolution since the temp dir
// has no node_modules. Pre-resolving to an absolute path bypasses this.
const mutCjsExportsPlugin = path.dirname(
require.resolve('@swc-contrib/mut-cjs-exports/package.json')
);
module.exports = {
...nxPreset,
testTimeout: 35000,
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
transform: {
'^.+\\.(html)$': 'ts-jest',
'^.+\\.[tj]sx?$': [
'@swc/jest',
{
jsc: {
parser: { syntax: 'typescript', dynamicImport: true },
transform: {
useDefineForClassFields: false,
},
experimental: {
plugins: [[mutCjsExportsPlugin, {}]],
},
},
module: { type: 'commonjs' },
},
],
},
resolver: '../../scripts/patched-jest-resolver.js',
moduleFileExtensions: ['ts', 'js', 'html'],
coverageReporters: ['html'],
maxWorkers: 1,
testEnvironment: 'node',
setupFiles: ['../../scripts/unit-test-setup.js'],
moduleNameMapper: {
// Mock ora to avoid ESM issues - ora@9+ is ESM-only and breaks Jest
'^ora$': '<rootDir>/../../scripts/jest-mocks/ora.js',
// Handle both `import * as x` and `import x from` styles for CommonJS modules
'^chalk$': '<rootDir>/../../scripts/jest-mocks/chalk.js',
'^yargs-parser$': '<rootDir>/../../scripts/jest-mocks/yargs-parser.js',
'^prettier$': '<rootDir>/../../scripts/jest-mocks/prettier.js',
},
};