Repository navigation
Expand file tree
/
Copy pathjest.config.js
More file actions
82 lines (69 loc) · 1.67 KB
/
Copy pathjest.config.js
File metadata and controls
82 lines (69 loc) · 1.67 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
79
80
81
82
/**
* Jest 测试框架配置
*/
module.exports = {
// 测试环境
testEnvironment: 'jsdom',
// 覆盖率提供器:使用 V8 替代 babel-plugin-istanbul(兼容 Node.js 22+)
coverageProvider: 'v8',
// 测试文件匹配模式
testMatch: [
'**/tests/**/*.test.js',
'**/tests/**/*.spec.js',
'**/__tests__/**/*.js'
],
// 忽略的文件/目录
testPathIgnorePatterns: [
'/node_modules/',
'/dist/',
'/netlify/',
'/.netlify/'
],
// 覆盖率收集
collectCoverageFrom: [
'src/js/modules/**/*.js',
'src/giffgaff/js/modules/**/*.js',
'src/simyo/js/modules/**/*.js',
'!src/js/modules/**/*.test.js',
'!src/js/modules/**/*.spec.js',
'!src/giffgaff/js/modules/**/*.test.js',
'!src/giffgaff/js/modules/**/*.spec.js',
'!src/simyo/js/modules/**/*.test.js',
'!src/simyo/js/modules/**/*.spec.js',
'!**/node_modules/**',
'!**/dist/**'
],
// 覆盖率报告格式
coverageReporters: [
'text',
'text-summary',
'html',
'lcov'
],
// 覆盖率阈值(逐步提升:当前 34% statements,目标 60%)
coverageThreshold: {
global: {
branches: 70,
functions: 65,
lines: 30,
statements: 30
}
},
// 模块名映射
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'],
// 详细输出
verbose: true,
// 清除模拟
clearMocks: true,
// 恢复模拟
restoreMocks: true
};