Files
happy-life-star/web-new/vitest.config.ts
T

77 lines
1.4 KiB
TypeScript

import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
export default defineConfig({
plugins: [vue()],
test: {
// 测试环境
environment: 'jsdom',
// 全局测试设置
globals: true,
// 测试文件匹配模式
include: [
'src/**/*.{test,spec}.{js,ts,vue}',
'tests/unit/**/*.{test,spec}.{js,ts,vue}'
],
// 排除文件
exclude: [
'node_modules',
'dist',
'cypress',
'tests/e2e'
],
// 覆盖率配置
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
reportsDirectory: './coverage',
exclude: [
'node_modules/',
'src/main.ts',
'src/vite-env.d.ts',
'**/*.d.ts',
'tests/',
'coverage/',
'dist/',
'**/*.config.{js,ts}',
'src/assets/',
'src/styles/',
'public/'
],
thresholds: {
global: {
branches: 70,
functions: 70,
lines: 70,
statements: 70
}
}
},
// 设置文件
setupFiles: ['./tests/setup.ts'],
// 测试超时时间
testTimeout: 10000,
// 并发运行
threads: true,
// 监听模式下的配置
watch: {
exclude: ['node_modules', 'dist']
}
},
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'~': resolve(__dirname, 'src')
}
}
})