/
jest.config.ts
97 lines (88 loc) · 2.58 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* eslint-disable global-require */
/* eslint-disable no-console */
/* eslint-disable import/no-unresolved */
const NO_COVERAGE = process.env.NO_COVERAGE === "1";
const CLEAR_CONSOLE = process.env.CLEAR_CONSOLE === "1";
const notice = () =>
console.log("Using Jest config from `jest.config.ts`");
if (CLEAR_CONSOLE) {
require("clear")();
console.log();
notice();
console.log("Clearing console due to CLEAR_CONSOLE=1");
} else {
notice();
}
if (NO_COVERAGE) {
console.log("Coverage not collected due to NO_COVERAGE=1");
}
console.log(
"Type checking is disabled during Jest for performance reasons, use `jest typecheck` when necessary."
);
module.exports = {
rootDir: __dirname,
roots: ["<rootDir>"],
cache: true,
verbose: true,
cacheDirectory: "<rootDir>/tmp/jest",
moduleFileExtensions: ["ts", "tsx", "js", "json"],
// preset configs
// preset: 'ts-jest/presets/js-with-ts',
// which files to test and which to ignore
preset: "ts-jest",
testMatch: [
"**/__tests__/*.test.(ts|tsx)",
"**/__tests__/*.spec.(ts|tsx)",
],
testEnvironment: "jsdom",
testPathIgnorePatterns: [
"/node_modules/",
"/tmp/",
"/coverage/",
"/stories/",
"/\\.storybook/",
"/dist/",
],
// don't watch for file changes in node_modules
watchPathIgnorePatterns: ["/node_modules/"],
// jest automock settings
automock: false,
unmockedModulePathPatterns: ["/node_modules/"],
// test environment setup
// setupFiles: [`${__dirname}/setup/setup.js`],
// setupFilesAfterEnv: [`${__dirname}/setup/setupAfterEnv.ts`],
// coverage settings
collectCoverage: NO_COVERAGE === false,
collectCoverageFrom: NO_COVERAGE
? []
: ["**/*.{ts,tsx}", "!**/*.d.ts", "!**/node_modules/**"],
coveragePathIgnorePatterns: [
"/node_modules/",
"\\.json$",
"/__tests__/",
"/stories/",
"/\\.storybook/",
],
globals: {
"ts-jest": {
tsconfig: `${__dirname}/tsconfig.json`,
// https://huafu.github.io/ts-jest/user/config/diagnostics
diagnostics: false,
// Makes jest test run much faster, BUT, without type checking.
// Type checking in CI is done with `tsc --noEmit` or `yarn typecheck` command.
// https://huafu.github.io/ts-jest/user/config/isolatedModules
isolatedModules: true,
},
},
transformIgnorePatterns: [
"/node_modules/(?!(lodash-es|antd|[^/]+/es|rc-animate|rc-util)/).*",
],
transform: {
"\\.(ts|tsx)$": "ts-jest",
"/node_modules/((lodash-es|[^/]+/es)|rc-animate|rc-util)/.*":
"ts-jest",
},
moduleNameMapper: {
d3: "<rootDir>/node_modules/d3/dist/d3.min.js",
},
};