- 安装 vitest + @testing-library/react + @testing-library/jest-dom + jsdom - 创建 vitest.config.ts (jsdom 环境, 全局 API, e2e 目录排除) - 创建 test/setup.ts (@testing-library/jest-dom 匹配器) - 添加 29 个测试用例: health 常量 (14), useThemeMode hook (2), StatusTag 组件 (13)
19 lines
394 B
TypeScript
19 lines
394 B
TypeScript
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: ['./src/test/setup.ts'],
|
|
exclude: ['e2e/**', 'node_modules/**'],
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
})
|