-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
88 lines (74 loc) · 2.17 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
84
85
86
87
88
const {join} = require('node:path');
const escape = require('escape-string-regexp');
const TARGETS = {
BABEL_FILES: '^.+\\.[jt]sx?$',
UNSUPPORTED_FILES: '^(?!.*\\.(js|jsx|ts|tsx|json)$)',
CSS_MODULES: '\\.module\\.css$'
};
const getPath = (p) => join(__dirname, p);
const OUTPUT_DIRNAME = '.test';
/*
* Useful Resources:
* https://jestjs.io/docs/configuration
* https://jestjs.io/docs/webpack
* https://github.com/facebook/create-react-app/blob/main/packages/react-scripts/scripts/utils/createJestConfig.js
*/
/*
* Issues:
* https://github.com/facebook/jest/issues/7331
*/
module.exports = {
roots: ['<rootDir>/src'],
testMatch: ['<rootDir>/src/**/*.test.{ts,tsx}'],
setupFilesAfterEnv: ['<rootDir>/src/jest.setup.ts'],
clearMocks: true,
resetMocks: true,
restoreMocks: true,
slowTestThreshold: 2,
testLocationInResults: true,
errorOnDeprecated: true,
testEnvironment: 'jsdom',
testEnvironmentOptions: {
url: 'https://localhost'
},
collectCoverage: true,
collectCoverageFrom: [
'<rootDir>/src/**/*.{ts,tsx}',
'!<rootDir>/src/stories/**/*.{ts,tsx}',
'!<rootDir>/src/**/*.stories.{ts,tsx}',
'!<rootDir>/src/**/index.{ts,tsx}'
],
coveragePathIgnorePatterns: ['/node_modules/', escape('/.yarn/')],
coverageDirectory: `<rootDir>/${OUTPUT_DIRNAME}/coverage`,
coverageReporters: ['json', 'text', 'lcov', 'clover'],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100
}
},
reporters: [
'default',
[
'jest-junit',
{
outputDirectory: `<rootDir>/${OUTPUT_DIRNAME}/reports`,
outputName: 'junit',
uniqueOutputName: 'true'
}
]
],
moduleNameMapper: {
[TARGETS.CSS_MODULES]: 'identity-obj-proxy'
},
transform: {
[TARGETS.BABEL_FILES]: [
'babel-jest',
{configFile: getPath('./babel.config.js')}
],
[TARGETS.UNSUPPORTED_FILES]: getPath('./.jest/jest.transform.file.js')
},
verbose: true
};