import { defineConfig } from 'vitest/config'; import react from '@vitejs/plugin-react'; import path from 'path'; export default defineConfig({ plugins: [react()], test: { environment: 'jsdom', globals: true, setupFiles: ['./vitest.setup.ts'], include: ['**/*.{test,spec}.{ts,tsx}'], exclude: ['**/node_modules/**', '**/e2e/**'], coverage: { provider: 'v8', reporter: ['text', 'json', 'html', 'lcov'], reportsDirectory: './coverage', thresholds: { global: { branches: 70, functions: 70, lines: 70, statements: 70, }, }, exclude: [ '**/node_modules/**', '**/*.d.ts', '**/types/**', '**/index.ts', '**/*.config.*', '**/vitest.setup.ts', '**/constants/**', // 常量文件无需测试 ], }, }, resolve: { alias: { '@': path.resolve(__dirname, './'), '@/components': path.resolve(__dirname, './components'), '@/constants': path.resolve(__dirname, './constants'), '@/styles': path.resolve(__dirname, './styles'), '@/lib': path.resolve(__dirname, './lib'), '@/hooks': path.resolve(__dirname, './hooks'), '@/types': path.resolve(__dirname, './types'), }, }, });