-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjest.config.ts
36 lines (32 loc) · 1.05 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
import { pathsToModuleNameMapper, GlobalConfigTsJest } from "ts-jest";
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 tsJestConfig: GlobalConfigTsJest = {
"ts-jest": {
tsconfig: "tsconfig.json",
compiler: "typescript",
},
};
const jestSetting = {
setupFiles: ["<rootDir>/.jest/setupEnv.js"],
globals: tsJestConfig,
moduleFileExtensions: ["ts", "tsx", "js", "json"],
roots: ["<rootDir>"],
modulePaths: ["<rootDir"],
moduleNameMapper: pathsToModuleNameMapper(compilerOptionsPaths),
moduleDirectories: ["node_modules", "src"],
modulePathIgnorePatterns: ["dist"],
testRegex: "\\.spec|\\.test\\.ts$",
transform: {
"^.+\\.ts$": "ts-jest",
},
};
export default jestSetting;