-
Notifications
You must be signed in to change notification settings - Fork 7
/
jest.config.yp.js
65 lines (57 loc) · 1.52 KB
/
jest.config.yp.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
let path = require('path');
let ypConfig = {
// TODO coverage is disabled due to https://github.com/facebook/jest/issues/3959
collectCoverage: false,
collectCoverageFrom: [
'**/lib/**/*.js'
],
coveragePathIgnorePatterns: [
'<rootDir>/node_modules/'
],
coverageReporters: [
'json',
'html',
'lcov',
'text'
],
notify: false,
testEnvironment: 'node',
testMatch: [
'**/test/**/*.test.js'
],
testPathIgnorePatterns: [
'<rootDir>/node_modules/'
],
transform: {},
transformIgnorePatterns: [
'<rootDir>/node_modules/'
],
watchPathIgnorePatterns: [
'<rootDir>/node_modules/'
]
};
// only add babel-jest transformer if babel-jest is a top-level dependency
try {
require.resolve('babel-jest');
let jestConfigModule = module;
while (jestConfigModule.parent) {
if (path.basename(jestConfigModule.filename) !== 'jest.config.js') {
jestConfigModule = jestConfigModule.parent;
continue;
}
break;
}
let topPackageJson = path.join(path.dirname(jestConfigModule.filename), 'package.json');
// eslint-disable-next-line global-require
let topPackage = require(topPackageJson);
if (!topPackage.devDependencies['babel-jest']) {
throw new Error(`babel-jest is not a dev dependency in ${topPackageJson}`);
}
ypConfig.transform['^.+\\.js$'] = 'babel-jest';
if (topPackage.devDependencies['@babel/preset-typescript']) {
ypConfig.transform['^.+\\.ts$'] = 'babel-jest';
}
} catch (_err) {
// console.log(_err);
}
module.exports = ypConfig;