0e9d4ae43e
environmentMatchGlobs 在 Vitest 4 中已移除,改用 projects 配置; 排除 vitest.config.ts 不参与 Next.js 类型检查。
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import react from "@vitejs/plugin-react";
|
|
import path from "path";
|
|
|
|
const shared = {
|
|
globals: true,
|
|
setupFiles: ["src/__tests__/helpers/setup.ts"],
|
|
env: {
|
|
AMAP_API_KEY: "test-amap-key",
|
|
DEEPSEEK_API_KEY: "test-deepseek-key",
|
|
},
|
|
} as const;
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "src"),
|
|
},
|
|
},
|
|
test: {
|
|
projects: [
|
|
{
|
|
plugins: [react()],
|
|
resolve: { alias: { "@": path.resolve(__dirname, "src") } },
|
|
test: {
|
|
...shared,
|
|
name: "ui",
|
|
environment: "jsdom",
|
|
include: ["src/**/*.test.{ts,tsx}"],
|
|
exclude: ["src/app/api/**", "src/lib/**/*.test.ts"],
|
|
},
|
|
},
|
|
{
|
|
resolve: { alias: { "@": path.resolve(__dirname, "src") } },
|
|
test: {
|
|
...shared,
|
|
name: "api",
|
|
environment: "node",
|
|
include: ["src/app/api/**/*.test.ts", "src/lib/**/*.test.ts"],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|