-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.ts
73 lines (65 loc) · 1.91 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import type { Config } from "@jest/types";
// Sync object
const nativeConfig: Config.InitialOptions = {
verbose: true,
testMatch: ["__tests__/**/*.test.ts"],
transform: {
"^.+\\.tsx?$": "ts-jest",
},
};
import type { JestConfigWithTsJest } from "ts-jest";
const jestConfigOne: JestConfigWithTsJest = {
// [...]
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
},
],
},
};
const jestConfig: JestConfigWithTsJest = {
// [...]
preset: "ts-jest/presets/default-esm", // or other ESM presets
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
// '^.+\\.[tj]sx?$' \\ to process js/ts with `ts-jest`
//to process js/ts/mjs/mts with `ts-jest`
"^.+\\.m?[tj]sx?$":
// "^.+\\.tsx?$":
[
"ts-jest",
{
useESM: true,
},
],
},
};
// export default nativeConfig;
// export default jestConfig;
// import { pathsToModuleNameMapper } from "ts-jest";
// In the following statement, replace `./tsconfig` with the path to your `tsconfig` file
// which contains the path mapping (ie the `compilerOptions.paths` option):
// import { compilerOptions } from "./tsconfig.json";
// import { compilerOptions } from "./tsconfig.json" assert { type: "json" };
// import type { JestConfigWithTsJest } from "ts-jest";
const jestConfigWithHelper: JestConfigWithTsJest = {
preset: "ts-jest/presets/default-esm", // or other ESM presets
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/dist/"],
// [...]
// roots: ["<rootDir>"],
// modulePaths: [compilerOptions.baseUrl], // <-- This will be set to 'baseUrl' value
// moduleNameMapper: pathsToModuleNameMapper(
// compilerOptions.paths /*, { prefix: '<rootDir>/' } */
// ),
};
export default jestConfigWithHelper;