Files
no-whatever/vitest.config.ts
T
kurihada 0e9d4ae43e fix: 修复 Vitest 4.x 构建兼容性问题
environmentMatchGlobs 在 Vitest 4 中已移除,改用 projects 配置;
排除 vitest.config.ts 不参与 Next.js 类型检查。
2026-03-01 21:51:14 +08:00

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"],
},
},
],
},
});