import { defineConfig } from 'vitest/config'; import vue from '@vitejs/plugin-vue'; import { fileURLToPath, URL } from 'node:url'; export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), '~': fileURLToPath(new URL('./src', import.meta.url)) }, }, test: { 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'] }, });