test: 添加完整测试套件(52 个文件,326 个用例)

基于 Vitest 搭建测试基础设施,覆盖后端纯函数、API 路由、
前端 hooks、UI 组件和页面级集成测试。
This commit is contained in:
2026-02-28 20:19:14 +08:00
parent 11eeec868e
commit 3ccd1262f9
59 changed files with 8131 additions and 3 deletions
+25
View File
@@ -0,0 +1,25 @@
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
test: {
globals: true,
environment: "jsdom",
setupFiles: ["src/__tests__/helpers/setup.ts"],
environmentMatchGlobs: [
["src/app/api/**/*.test.ts", "node"],
["src/lib/**/*.test.ts", "node"],
],
env: {
AMAP_API_KEY: "test-amap-key",
DEEPSEEK_API_KEY: "test-deepseek-key",
},
},
});