45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
||
import vue from '@vitejs/plugin-vue';
|
||
import { fileURLToPath, URL } from 'node:url';
|
||
|
||
export default defineConfig({
|
||
plugins: [vue()],
|
||
resolve: {
|
||
// import.meta是ESM运行时元信息,import.meta.url时当前目录路径
|
||
alias: {
|
||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||
'~': fileURLToPath(new URL('./src', import.meta.url))
|
||
},
|
||
},
|
||
test: {
|
||
// 这里都没用啊,因为组合环境的问题,vitest会出现IPC通信报错,暂时无法解决
|
||
timeout: 60000, // 60秒超时
|
||
globals: true,
|
||
environment: 'jsdom', // Vue组件测试需要浏览器环境
|
||
threads: false, // 禁用多线程以解决线程相关报错
|
||
coverage: {
|
||
provider: 'v8',
|
||
reporter: ['text', 'json', 'html'],
|
||
exclude: [
|
||
'node_modules/',
|
||
'dist/',
|
||
'**/*.config.js',
|
||
'**/*.config.ts',
|
||
'**/*.d.ts',
|
||
'**/index.ts',
|
||
'**/*.test.ts',
|
||
'**/*.spec.ts',
|
||
],
|
||
thresholds: {
|
||
global: {
|
||
branches: 80,
|
||
functions: 80,
|
||
lines: 80,
|
||
statements: 80,
|
||
},
|
||
},
|
||
},
|
||
setupFiles: ['./test/setup.ts'], // 全局测试设置
|
||
include: ['src/**/*.test.ts', 'src/**/*.spec.ts']
|
||
},
|
||
}); |