-
Notifications
You must be signed in to change notification settings - Fork 3
/
jest.config.js
119 lines (115 loc) · 3.96 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
113
114
115
116
117
118
119
/** @type {import('ts-jest').JestConfigWithTsJest} */
// these paths must be specified because otherwise typescript relies on the
// "main" field in each package.json file, which points to the compiled JS and
// we want to run Jest against the TS source
const paths = {
'@bugsnag/core-performance': ['./packages/core/lib/index.ts'],
'@bugsnag/browser-performance': ['./packages/platforms/browser/lib/index.ts'],
'@bugsnag/delivery-fetch-performance': ['./packages/delivery-fetch/lib/delivery.ts'],
'@bugsnag/request-tracker-performance': ['./packages/request-tracker/lib/index.ts'],
'@bugsnag/react-router-performance': ['./packages/react-router/lib/index.ts'],
'@bugsnag/vue-router-performance': ['./packages/vue-router/lib/index.ts'],
'@bugsnag/angular-performance': ['./packages/angular/lib/index.ts'],
'@bugsnag/plugin-react-native-navigation-performance': ['./packages/plugin-react-native-navigation/lib/index.ts'],
'@bugsnag/plugin-react-navigation-performance': ['./packages/plugin-react-navigation/lib/index.ts']
}
// convert the tsconfig "paths" option into Jest's "moduleNameMapper" option
// e.g.: "{ 'path': ['./a/b'] }" -> "{ '^path$': ['<rootDir>/a/b'] }"
const moduleNameMapper = Object.fromEntries(
Object.entries(paths)
.map(([name, directories]) => [
`^${name}$`,
directories.map(directory => directory.replace('./', '<rootDir>/'))
])
)
const defaultModuleConfig = {
preset: 'ts-jest/presets/js-with-ts',
moduleNameMapper,
transform: {
'^.+\\.m?[tj]sx?$': [
'ts-jest',
{ tsconfig: { paths, allowJs: true } }
]
}
}
module.exports = {
projects: [
{
displayName: 'core',
testMatch: ['<rootDir>/packages/core/**/*.test.ts'],
...defaultModuleConfig
},
{
displayName: 'delivery-fetch',
testMatch: ['<rootDir>/packages/delivery-fetch/**/*.test.ts'],
...defaultModuleConfig
},
{
displayName: 'browser',
testMatch: ['<rootDir>/packages/platforms/browser/**/*.test.ts'],
...defaultModuleConfig
},
{
displayName: 'request-tracker',
testMatch: ['<rootDir>/packages/request-tracker/**/*.test.ts'],
...defaultModuleConfig
},
{
displayName: 'vue-router',
testMatch: ['<rootDir>/packages/vue-router/**/*.test.ts'],
...defaultModuleConfig
},
{
displayName: 'react-router',
testMatch: ['<rootDir>/packages/react-router/**/*.test.ts'],
...defaultModuleConfig
},
{
displayName: 'angular',
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/jest/setup/angular.ts'],
testMatch: ['<rootDir>/packages/angular/**/*.test.ts'],
...defaultModuleConfig,
transformIgnorePatterns: ['/node_modules/(?!(@angular)/)']
},
{
displayName: 'react-native',
preset: 'react-native',
testMatch: ['<rootDir>/packages/platforms/react-native/tests/**/*.test.ts'],
coveragePathIgnorePatterns: ['<rootDir>/packages/core', '<rootDir>/packages/platforms/browser', '<rootDir>/packages/delivery-fetch'],
moduleNameMapper,
transform: {
'^.+\\.jsx?$': [
'babel-jest',
{
presets: ['module:metro-react-native-babel-preset']
}
],
'^.+\\.m?tsx?$': [
'ts-jest',
{
tsconfig: { paths },
babelConfig: {
presets: ['module:metro-react-native-babel-preset']
}
}
]
}
},
'<rootDir>/jest/config/react-navigation.js',
'<rootDir>/jest/config/react-native-navigation.js'
],
collectCoverageFrom: [
'**/packages/*/**/*.ts',
'!**/packages/*/**/*.d.ts',
'!**/packages/*/**/*.test.ts',
'!**/packages/*/**/tests/**/*',
'!**/packages/*/**/__tests__/**/*',
'!<rootDir>/packages/test-utilities/**/*',
'!<rootDir>/test/**/*'
],
coverageReporters: ['json-summary', 'text'],
reporters: process.env.CI
? [['github-actions', { silent: false }], 'summary']
: ['default']
}