Files
hunjing/frontend/vitest.config.ts
T
2026-08-21 16:00:13 +08:00

32 lines
872 B
TypeScript

import { fileURLToPath } from "node:url";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vitest/config";
/**
* Vitest 配置。
* - environment=jsdom:支持组件渲染测试;纯函数测试同样兼容。
* - globals=true:直接使用 describe/it/expect,无需逐文件 import。
* - alias @/* → src/*:与 tsconfig paths 一致。
*/
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
test: {
environment: "jsdom",
globals: true,
setupFiles: ["./src/test/setup.ts"],
include: ["src/**/*.{test,spec}.{ts,tsx}"],
coverage: {
provider: "v8",
reporter: ["text", "html"],
include: ["src/lib/**", "src/components/**"],
exclude: ["src/**/*.test.{ts,tsx}", "src/test/**"],
},
},
});