-
Notifications
You must be signed in to change notification settings - Fork 29
/
vitest.config.mts
54 lines (52 loc) · 1.52 KB
/
vitest.config.mts
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
import { defineConfig } from 'vitest/config'
import path from 'path'
// 抽取重复的模块路径
const modulePaths = [
'@wangeditor-next/core',
'@wangeditor-next/basic-modules',
'@wangeditor-next/code-highlight',
'@wangeditor-next/editor',
'@wangeditor-next/list-module',
'@wangeditor-next/table-module',
'@wangeditor-next/upload-image-module',
'@wangeditor-next/video-module',
]
export default defineConfig({
test: {
environment: 'jsdom', // Vitest 默认使用 jsdom
include: ['**/*.test.{ts,js,tsx}'], // 对应的测试匹配模式
globals: true, // 如果需要全局的 vi 函数
setupFiles: path.resolve(__dirname, 'tests/setup/index.ts'), // 对应 setup 文件
coverage: {
reporter: ['text', 'json', 'html'], // 覆盖率报告格式
include: [
`packages/{${modulePaths.map(p => p.split('/')[1]).join(',')}}/src/**/*.{ts,tsx}`,
],
exclude: [
'dist',
'locale',
'index.ts',
'config.ts',
'browser-polyfill.ts',
'node-polyfill.ts',
], // 忽略覆盖率计算的文件
},
},
resolve: {
alias: {
// 对于样式文件 mock
'^.+\\.(css|less)$': path.resolve(__dirname, 'tests/utils/stylesMock.js'),
...Object.fromEntries(
modulePaths.map(p => [
`${p}/dist/css/style.css`,
path.resolve(__dirname, 'tests/utils/stylesMock.js')
])
),
},
},
esbuild: {
// 如果需要特定的转译处理
jsx: 'transform',
jsxFactory: 'jsx',
},
})