-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.js
48 lines (44 loc) · 1.41 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
const stringToBoolean = (val) => {
if (val == null) {
return false;
}
if (typeof val !== 'string') {
throw new Error(`Cannot parse value "${val}" (expected a string but received a ${typeof val})`);
}
switch (val.trim().toLowerCase()) {
case '1':
case 'true':
return true;
case '0':
case 'false':
return false;
}
throw new Error(`Could not parse unexpected value "${val}" as a boolean`);
};
/**
* Jest configuration for unit tests.
*
* Coverage reporting is automatically enabled in CI environments; enable it locally by setting
* `COVERAGE=true`.
*/
module.exports = {
collectCoverage: stringToBoolean(process.env.CI) || stringToBoolean(process.env.COVERAGE),
collectCoverageFrom: ['**/*.{ts,tsx,js,jsx}'],
coveragePathIgnorePatterns: [
// Ignore configuration files (e.g. jest.config.js, webpack.config.js, )
'<rootDir>/.+\\.config(\\.babel)?\\.js',
// Ignore rc files (e.g. .prettierrc.js, .eslintrc.js, etc.)
'<rootDir>/\\..+rc\\.js',
// Ignore coverage report support files
'<rootDir>/coverage/',
// Ignore compiled source
'<rootDir>/lib/',
],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json'],
testMatch: ['**/?(*.)test.!(*.){js,jsx,ts,tsx}'],
testPathIgnorePatterns: ['<rootDir>/lib/', '<rootDir>/node_modules/'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
},
watchPathIgnorePatterns: ['<rootDir>/lib'],
};