-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
84 lines (82 loc) · 2.37 KB
/
vitest.config.ts
File metadata and controls
84 lines (82 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import { loadEnv } from "vite";
import path from "path";
export default defineConfig(({ mode }) => {
// Load .env.local for tests
const env = loadEnv(mode, process.cwd(), "");
return {
plugins: [react()],
test: {
globals: true,
environment: "node",
setupFiles: ["./src/test/setup.ts"],
env: {
...env,
// Pass through POSTGRES_URL if available (omit to let setup.ts fallback work)
...(env.POSTGRES_URL || process.env.POSTGRES_URL
? { POSTGRES_URL: env.POSTGRES_URL || process.env.POSTGRES_URL }
: {}),
},
coverage: {
provider: "v8",
reporter: ["text", "json", "html", "lcov"],
include: ["src/**/*.{ts,tsx}"],
exclude: [
"src/**/*.test.{ts,tsx}",
"src/test/**",
"src/app/**", // Server Components tested via E2E
"src/components/ui/**", // shadcn/ui library components
"**/*.d.ts",
"**/types.ts",
"**/*.config.{ts,js}",
],
// No thresholds enforced in CI
},
// Project-based test suites
projects: [
{
extends: true,
test: {
name: "unit",
environment: "jsdom",
include: ["src/**/*.test.ts", "src/**/*.test.tsx"],
exclude: ["src/test/integration/**"],
},
},
{
extends: true,
test: {
name: "integration",
include: [
"src/test/integration/**/*.test.ts",
"src/test/integration/**/*.test.tsx",
],
exclude: ["src/test/integration/supabase/**"],
},
},
{
extends: true,
test: {
name: "integration-supabase",
include: [
"src/test/integration/supabase/**/*.test.ts",
"src/test/integration/supabase/**/*.test.tsx",
],
},
},
],
},
resolve: {
alias: {
"~": path.resolve(__dirname, "./src"),
// server-only is a Next.js convention that errors in client bundles.
// In Vitest (Node.js), we resolve it to an empty module.
"server-only": path.resolve(
__dirname,
"./src/test/mocks/server-only.ts"
),
},
},
};
});