test: 引入 Vitest 测试骨架并抽出颜色/比例纯函数模块

This commit is contained in:
2026-06-15 13:39:02 +08:00
parent 307537a7ce
commit 45e6534ee1
12 changed files with 3773 additions and 199 deletions
+16
View File
@@ -0,0 +1,16 @@
import { defineConfig } from "vitest/config";
// Vitest 配置独立于 vite.config.ts,避免影响 dev/build。
// 本轮只测纯函数(颜色/比例/平台/路由/错误翻译),用 node 环境即可,无需 jsdom。
// 后续要做组件测试时,再在 test.environment 切到 jsdom 并装 @testing-library/react。
export default defineConfig({
test: {
environment: "node",
include: ["src/**/*.{test,spec}.{ts,tsx}"],
coverage: {
provider: "v8",
include: ["src/**/*.{ts,tsx}"],
exclude: ["src/**/*.test.*", "src/**/*.spec.*", "src/main.tsx", "src/vite-env.d.ts"],
},
},
});