-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
68 lines (65 loc) · 2.14 KB
/
Copy pathvitest.config.ts
File metadata and controls
68 lines (65 loc) · 2.14 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
import 'dotenv/config';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitest/config';
const rootAlias = { '@': fileURLToPath(new URL('.', import.meta.url)) };
export default defineConfig({
resolve: { alias: rootAlias },
test: {
projects: [
{
resolve: {
alias: {
'server-only': fileURLToPath(
new URL('./tests/stubs/server-only.ts', import.meta.url),
),
...rootAlias,
},
},
test: {
name: 'unit',
environment: 'node',
// Deliberately not the org timezone — any accidental host-zone
// dependence in lib/dates.ts fails loudly instead of passing by luck.
env: { TZ: 'Asia/Tokyo' },
include: ['tests/unit/**/*.test.ts'],
},
},
{
resolve: {
// More specific aliases first — Vite matches in order, and '@' would
// otherwise shadow '@/lib/auth/server' as a prefix match.
alias: {
'@/lib/auth/server': fileURLToPath(
new URL('./tests/stubs/auth-server.ts', import.meta.url),
),
'@/lib/delay': fileURLToPath(
new URL('./tests/stubs/delay.ts', import.meta.url),
),
'@vercel/blob': fileURLToPath(
new URL('./tests/stubs/vercel-blob.ts', import.meta.url),
),
'next/cache': fileURLToPath(
new URL('./tests/stubs/next-cache.ts', import.meta.url),
),
'next/server': fileURLToPath(
new URL('./tests/stubs/next-server.ts', import.meta.url),
),
'server-only': fileURLToPath(
new URL('./tests/stubs/server-only.ts', import.meta.url),
),
...rootAlias,
},
},
test: {
name: 'db',
environment: 'node',
env: { TZ: 'America/New_York' },
include: ['tests/db/**/*.test.ts'],
globalSetup: ['tests/global-setup.ts'],
// One database, no cross-file interleaving.
fileParallelism: false,
},
},
],
},
});