-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.js
32 lines (25 loc) · 892 Bytes
/
jest.config.js
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
/** @type {import('jest').Config} */
const path = require("path");
function makeModuleNameMapper(srcPath, tsconfigPath) {
const { paths } = require(tsconfigPath).compilerOptions;
const aliases = {};
Object.keys(paths).forEach((item) => {
const key = item.replace(/\/\*$/, "/(.*)");
const path = paths[item][0].replace(/\/\*$/, "/$1");
aliases[key] = srcPath + "/" + path;
});
return aliases;
}
const TS_CONFIG_PATH = "./tsconfig.json";
const SRC_PATH = "<rootDir>/src";
const config = {
moduleNameMapper: makeModuleNameMapper(SRC_PATH, TS_CONFIG_PATH),
moduleDirectories: ["node_modules", "src"],
testMatch: ["**/__tests__/**/*.test.+(ts|tsx|js)"],
transform: {
"^.+\\.(ts|tsx)$": "ts-jest",
},
testPathIgnorePatterns: ["/dist/", "/node_modules/"],
setupFilesAfterEnv: ["<rootDir>/src/lib/__tests__/globalSetup.ts"],
};
module.exports = config;