The integration project now aliases server-only to a tiny empty stub so tests can import modules that carry 'import "server-only"' without the throwing real implementation firing during prepare. Unit tests do NOT get the alias — a pure module with a server import is exactly the kind of leak the unit project's missing condition is meant to surface.
43 lines
No EOL
1.2 KiB
TypeScript
43 lines
No EOL
1.2 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
export default defineConfig({
|
|
resolve: {
|
|
alias: { "@": path.resolve(__dirname, "./src") },
|
|
},
|
|
test: {
|
|
projects: [
|
|
{
|
|
resolve: { alias: { "@": path.resolve(__dirname, "./src") } },
|
|
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.
|
|
"server-only": fileURLToPath(
|
|
new URL("./src/lib/server-only-stub.ts", import.meta.url)
|
|
),
|
|
},
|
|
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 } },
|
|
},
|
|
},
|
|
],
|
|
},
|
|
}); |