-
-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathjest.config.js
55 lines (50 loc) · 1.38 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
let moduleNameMapper
const babel = [
'babel-jest',
{
overrides: [
{
test: '**/*.ts',
plugins: [
['@babel/plugin-transform-typescript', { allowDeclareFields: true }]
]
}
],
presets: [['@babel/env', { targets: { node: 'current' } }]]
}
]
const transform = {
'[/\\\\]tests[/\\\\].*\\.(m?js|ts)$': babel
}
// The npm script name is significant.
switch (process.env.npm_lifecycle_event) {
case 'test:dist':
console.log('Testing build output from dist/')
moduleNameMapper = {
'^yaml$': '<rootDir>/dist/index.js',
'^yaml/cli$': '<rootDir>/dist/cli.mjs',
'^yaml/util$': '<rootDir>/dist/util.js',
'^../src/test-events.ts$': '<rootDir>/dist/test-events.js'
}
transform['[/\\\\]dist[/\\\\].*\\.mjs$'] = babel
break
case 'test':
default:
process.env.TRACE_LEVEL = 'log'
moduleNameMapper = {
'^yaml$': '<rootDir>/src/index.ts',
'^yaml/cli$': '<rootDir>/src/cli.ts',
'^yaml/util$': '<rootDir>/src/util.ts'
}
transform['[/\\\\]src[/\\\\].*\\.ts$'] = babel
}
module.exports = {
collectCoverageFrom: ['src/**/*.{js,ts}', '!src/**/*.d.ts'],
moduleNameMapper,
resolver: 'jest-ts-webcompat-resolver',
rootDir: '..',
testEnvironment: 'node',
testMatch: ['**/tests/**/*.{js,ts}'],
testPathIgnorePatterns: ['tests/_utils', 'tests/json-test-suite/'],
transform
}