-
Notifications
You must be signed in to change notification settings - Fork 3
/
jest.config.js
52 lines (52 loc) · 1.48 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
/**
* @file config of jest
* @url https://jestjs.io/docs/en/configuration
*/
module.exports = {
moduleFileExtensions: ['js', 'ts', 'mpx'],
testEnvironment: 'jsdom',
collectCoverage: false,
testMatch: [
'**/__tests__/**/*.spec.js'
],
collectCoverageFrom: ['/packages/mpx-cube-ui/src/components/**/*.{js,mpx,ts}'],
coverageDirectory: 'test/coverage',
moduleNameMapper: {
'^src/(.*)': '<rootDir>/packages/mpx-cube-ui/src/$1',
'^test/(.*)': '<rootDir>/packages/mpx-cube-ui/__tests__/$1',
'^example/(.*)': '<rootDir>/example/$1',
'@mpxjs/core$': '<rootDir>/node_modules/@mpxjs/core/src/index.js',
'@mpxjs/api-proxy': '<rootDir>/node_modules/@mpxjs/api-proxy/src/index.js'
},
globals: {
__mpx_mode__: 'wx',
__env__: 'test',
'ts-jest': {
tsconfig: {
target: 'ES2019'
},
// ts-jest 处理后再经过 babel-jest 处理
babelConfig: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
]
]
}
}
},
testURL: 'http://test.api.com',
setupFiles: ['<rootDir>/scripts/test-setup.js'],
transform: {
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
'^.+\\.mpx$': '<rootDir>/node_modules/@mpxjs/mpx-jest',
'^.+\\.ts$': '<rootDir>/node_modules/ts-jest'
},
resolver: '<rootDir>/scripts/jest-mpx-resolver/index.js',
transformIgnorePatterns: ['node_modules/(?!(@mpxjs|@babel))']
}