-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
83 lines (80 loc) · 2.46 KB
/
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
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
74
75
76
77
78
79
80
81
82
83
const fs = require("fs");
const fileExtensions = [
"ts",
"tsx",
"mts",
"cts",
"js",
"jsx",
"mjs",
"cjs",
"node",
"json",
];
/** @type {Partial<import('@jest/types').Config.ProjectConfig>} */
const commonProjectsConfig = {
moduleDirectories: ["node_modules"],
moduleFileExtensions: fileExtensions,
moduleNameMapper: fs
.readdirSync("./src/", { withFileTypes: true })
.reduce((map, file) => {
if (file.isDirectory()) {
map[`^${file.name}/(.*)$`] = `<rootDir>/src/${file.name}/$1`;
} else if (fileExtensions.find(item => file.name.endsWith(`.${item}`))) {
const fileName = file.name.slice(0, file.name.lastIndexOf("."));
map[`^${fileName}$`] = `<rootDir>/src/${fileName}`;
}
return map;
}, {}),
modulePathIgnorePatterns: [
"<rootDir>/build",
"<rootDir>/dist",
"<rootDir>/.husky",
"<rootDir>/.vscode",
"<rootDir>/coverage",
],
rootDir: "./",
roots: ["<rootDir>/", "<rootDir>/src/"],
testEnvironment: "node",
testPathIgnorePatterns: [".husky/", ".vscode/", "dist/", "coverage/", "node_modules/"],
transformIgnorePatterns: [],
};
/** @type {Omit<import('@jest/types').Config.GlobalConfig, "projects"> & { projects: Array<import('@jest/types').Config.ProjectConfig> }} */
module.exports = {
maxWorkers: 3,
projects: [
{
displayName: "unit",
testMatch: ["<rootDir>/src/**/__tests__/**/unit/**/*.(spec|test).[tj]s?(x)"],
},
{
displayName: "integration",
testMatch: [
"<rootDir>/src/**/__tests__/**/integration/**/*.(spec|test).[tj]s?(x)",
],
},
{
displayName: "e2e",
testMatch: ["<rootDir>/src/**/__tests__/**/e2e/**/*.(spec|test).[tj]s?(x)"],
},
].map(obj => ({ ...commonProjectsConfig, ...obj })),
cache: false,
forceExit: true,
passWithNoTests: true,
collectCoverage: true,
collectCoverageFrom: [
"**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs,node}",
"!**/*.d.{ts,tsx,mts,cts}",
"!**/*.config.*",
"!**/node_modules/**",
"!**/.husky/**",
"!**/.vscode/**",
"!**/dist/**",
"!**/coverage/**",
"!**/__tests__/**",
"!**/__mocks__/**",
"!**/index.*",
],
coverageDirectory: "<rootDir>/coverage",
verbose: true,
};