kanban-dev-webapp/vitest.config.ts

54 lines
1.5 KiB
TypeScript
Raw Normal View History

import { defineConfig } from "vitest/config";
import path from "node:path";
import { fileURLToPath } from "node:url";
2026-09-19 16:35:33 +00:00
const serverOnlyStub = fileURLToPath(
new URL("./src/lib/server-only-stub.ts", import.meta.url)
);
export default defineConfig({
resolve: {
alias: { "@": path.resolve(__dirname, "./src") },
},
test: {
projects: [
{
2026-09-19 16:35:33 +00:00
// Unit tests can also import server-only modules (e.g.
// writeCardWithAudit) and replace the guard with the empty stub,
// matching the integration project's alias.
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"server-only": serverOnlyStub,
},
},
test: {
name: "unit",
environment: "node",
include: ["src/**/*.test.ts"],
},
},
{
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
// Replace server-only with the empty stub so integration tests
// can import server modules without "imported from a Client
// Component module" blowing up at prepare time.
2026-09-19 16:35:33 +00:00
"server-only": serverOnlyStub,
},
conditions: ["react-server", "node", "import", "default"],
},
test: {
name: "integration",
environment: "node",
include: ["tests/integration/**/*.test.ts"],
hookTimeout: 30_000,
testTimeout: 30_000,
poolOptions: { forks: { singleFork: true } },
},
},
],
},
2026-09-19 16:35:33 +00:00
});