-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathjest.config.js
More file actions
78 lines (65 loc) · 1.31 KB
/
jest.config.js
File metadata and controls
78 lines (65 loc) · 1.31 KB
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
/**
* Jest 测试框架配置
*/
module.exports = {
// 测试环境
testEnvironment: 'jsdom',
// 测试文件匹配模式
testMatch: [
'**/tests/**/*.test.js',
'**/tests/**/*.spec.js',
'**/__tests__/**/*.js'
],
// 忽略的文件/目录
testPathIgnorePatterns: [
'/node_modules/',
'/dist/',
'/netlify/',
'/.netlify/'
],
// 覆盖率收集
collectCoverageFrom: [
'src/**/*.js',
'!src/**/*.test.js',
'!src/**/*.spec.js',
'!**/node_modules/**',
'!**/dist/**'
],
// 覆盖率报告格式
coverageReporters: [
'text',
'text-summary',
'html',
'lcov'
],
// 覆盖率阈值
coverageThreshold: {
global: {
branches: 60,
functions: 60,
lines: 60,
statements: 60
}
},
// 模块名映射
moduleNameMapper: {
'\\.(css|less|scss|sass)$': '<rootDir>/tests/__mocks__/styleMock.js',
'\\.(gif|ttf|eot|svg|png|jpg|jpeg)$': '<rootDir>/tests/__mocks__/fileMock.js'
},
// 转换器配置
transform: {
'^.+\\.js$': 'babel-jest'
},
// 设置文件
setupFilesAfterEnv: ['<rootDir>/tests/setup.js'],
// 全局变量
globals: {
'NODE_ENV': 'test'
},
// 详细输出
verbose: true,
// 清除模拟
clearMocks: true,
// 恢复模拟
restoreMocks: true
};