-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjest.config.ts
51 lines (43 loc) · 1.31 KB
/
jest.config.ts
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
//#region JEST_CONFIG_ESM
const FLAG_JEST_ESM_NATIVE = process.env["NODE_OPTIONS"]?.includes(
"--experimental-vm-modules"
);
//#region adjustMe
const HARDCODE_ESMONLY = FLAG_JEST_ESM_NATIVE
? // no need to set
""
: // ESM-only `node-fetch` depends on ESM-only `fetch-blob`
// Just recursive it down.
"node-fetch|fetch-blob|@loynoir/example-";
//#endregion adjustMe
const JEST_CONFIG_ESM = FLAG_JEST_ESM_NATIVE
? {
preset: "ts-jest/presets/default-esm",
globals: {
"ts-jest": {
tsconfig: "<rootDir>/config/tsconfig.jest-ESM.json",
useESM: true,
},
},
}
: {
preset: "ts-jest/presets/js-with-ts-esm",
globals: {
"ts-jest": {
tsconfig: "<rootDir>/config/tsconfig.jest-ESM-soft.json",
},
},
// default: ["/node_modules/", "\\.pnp\\.[^\\\/]+$"]
// notice: `<rootDir>` is the place holder used by jest
// no need to replace it
transformIgnorePatterns: [
`<rootDir>/node_modules/(?!(\\.pnpm/.*?node_modules/|)(${HARDCODE_ESMONLY}))`,
`<rootDir>/\\.yarn/cache/.*?/node_modules/(?!${HARDCODE_ESMONLY})`,
"\\.pnp\\.[^\\/]+$",
],
};
//#endregion JEST_CONFIG_ESM
export default {
testMatch: ["<rootDir>/test/**/?(*.)+(spec|test).[tj]s?(x)"],
...JEST_CONFIG_ESM,
};