This repository has been archived by the owner on Jul 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
jest.config.js
112 lines (106 loc) · 2.62 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const commonSettings = {
testPathIgnorePatterns: [
'<rootDir>/bin',
'<rootDir>/coverage',
'<rootDir>/lib/',
'<rootDir>/node_modules/',
],
collectCoverageFrom: [
'<rootDir>/src/**/*.ts',
'!<rootDir>/src/test-helpers.ts',
'!<rootDir>/src/metrics.ts',
'!**/*.spec.ts',
'!**/*.d.ts',
'!**/types.ts',
"!**/jest-extensions.ts",
"!**/builders.ts",
"!**/*builders.ts",
"!**/*builder.ts"
],
testEnvironment: 'node',
watchPathIgnorePatterns: [
'<rootDir>\/black-box-tests\/test-environment.*',
'<rootDir>\/lib.*',
'<rootDir>\/coverage.*',
'test-helpers.ts'
],
setupFilesAfterEnv: ['<rootDir>/src/jest-extensions.ts']
}
const lowLevelTestSettings = {
moduleNameMapper: {
'~(.*)$': '<rootDir>/src/$1'
},
}
const unitTestSettings = {
...commonSettings,
...lowLevelTestSettings,
displayName: 'Unit',
testMatch: [
'<rootDir>/src/**/*.spec.ts',
'!**/*.integration.spec.ts',
],
unmockedModulePathPatterns: [
'<rootDir>/src/test-helpers.ts',
'<rootDir>/src/config-old/methods.ts',
'<rootDir>/src/config/types.ts',
'<rootDir>/src/shared/.*\.ts',
require.resolve('winston'),
require.resolve('@hapi/joi'),
require.resolve('chalk'),
require.resolve('strip-ansi'),
require.resolve('dot-object'),
],
automock: true,
coverageDirectory: './coverage/unit-tests',
coverageReporters: ["lcov", "text", "text-summary"],
}
const integrationTestSettings = {
...commonSettings,
...lowLevelTestSettings,
displayName: 'Integration',
testMatch: [
'**/*.integration.spec.ts'
],
coverageDirectory: './coverage/integration-tests',
coverageReporters: ["lcov", "text", "text-summary"],
}
const acceptanceTestSettings = {
...commonSettings,
displayName: 'Acceptance',
testMatch: [
'<rootDir>/black-box-tests/acceptance/**/*.spec.ts'
],
coverageDirectory: './coverage/acceptance-tests',
// using nyc to report the coverage instead
coverageReporters: ["none"],
preset: 'ts-jest',
globals: {
'ts-jest': {
tsconfig: './tsconfig.jest.json'
}
},
moduleNameMapper: {
'~shared(.*)$': '<rootDir>/black-box-tests/shared/$1',
...lowLevelTestSettings.moduleNameMapper,
},
}
switch (process.env.TEST_MODE) {
case 'unit':
module.exports = unitTestSettings
break
case 'integration':
module.exports = integrationTestSettings
break
case 'acceptance':
module.exports = acceptanceTestSettings
break
default:
module.exports = {
...commonSettings,
projects: [
unitTestSettings,
integrationTestSettings,
acceptanceTestSettings
],
}
}