-
-
Notifications
You must be signed in to change notification settings - Fork 210
/
Copy pathjest.config.js
58 lines (54 loc) · 1.71 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
/*
* @Author: weisheng
* @Date: 2025-03-24 12:33:15
* @LastEditTime: 2025-03-26 13:29:54
* @LastEditors: weisheng
* @Description:
* @FilePath: /wot-design-uni/jest.config.js
* 记得注释
*/
module.exports = {
testEnvironment: 'jsdom',
moduleFileExtensions: ['ts', 'js', 'json', 'vue'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'\\.(css|less|scss|sass)$': 'identity-obj-proxy'
},
transform: {
'^.+\\.ts$': 'ts-jest',
'^.+\\.js$': 'babel-jest',
'^.+\\.vue$': '@vue/vue3-jest'
},
testRegex: '(/tests/.*\\.spec)\\.(jsx?|tsx?)$', // 只匹配 .spec 结尾的文件
testPathIgnorePatterns: ['/node_modules/', '/tests/setup.js', '/tests/__mocks__/'],
// 添加 modulePathIgnorePatterns 配置,忽略 uni_modules 下的 package.json
modulePathIgnorePatterns: ['<rootDir>/src/uni_modules/.*', '<rootDir>/src/uni_modules/wot-design-uni/package.json'],
// 或者使用 watchPathIgnorePatterns
watchPathIgnorePatterns: ['<rootDir>/src/uni_modules/'],
// 增加全局超时时间设置
testTimeout: 10000, // 设置为10秒
globals: {
'vue-jest': {
compilerOptions: {
isCustomElement: (tag) => tag.startsWith('uni-'),
whitespace: 'condense',
delimiters: ['{{', '}}']
},
experimentalCoverage: true, // 添加实验性覆盖率支持
templateCompiler: {
compiler: require('@vue/compiler-dom'),
compilerOptions: {
hoistStatic: false,
prefixIdentifiers: true
}
}
},
'ts-jest': {
diagnostics: false,
isolatedModules: true,
babelConfig: true
}
},
transformIgnorePatterns: ['/node_modules/(?!(uni-app|@dcloudio)/)'],
setupFiles: ['<rootDir>/tests/setup.js']
}