-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.ts
49 lines (44 loc) · 1.17 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
import { pathsToModuleNameMapper, GlobalConfigTsJest } from "ts-jest";
import type { InitialOptionsTsJest } from "ts-jest/dist/types";
import ts from "typescript";
const compilerOptionsPaths = (() => {
const configFileName = ts.findConfigFile(
"../",
ts.sys.fileExists,
"tsconfig.json",
);
if (configFileName) {
const configFile = ts.readConfigFile(configFileName, ts.sys.readFile);
const option = ts.parseJsonConfigFileContent(
configFile.config,
ts.sys,
"./",
);
return option.raw.compilerOptions.paths;
}
return {};
})();
const globals: GlobalConfigTsJest = {
"ts-jest": {
tsconfig: "tsconfig.json",
compiler: "typescript",
},
};
const moduleNameMapper = pathsToModuleNameMapper(compilerOptionsPaths, {
prefix: "<rootDir>",
});
const jestSetting: InitialOptionsTsJest = {
setupFiles: ["<rootDir>/.jest/setupEnv.js"],
globals,
moduleFileExtensions: ["ts", "tsx", "js", "json"],
rootDir: ".",
roots: ["<rootDir>"],
modulePaths: ["<rootDir>"],
moduleNameMapper,
modulePathIgnorePatterns: ["dist"],
testRegex: ".spec|.test.ts$",
transform: {
"^.+.ts$": "ts-jest",
},
};
export default jestSetting;