-
-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathvitest.config.ts
More file actions
49 lines (43 loc) · 1.29 KB
/
vitest.config.ts
File metadata and controls
49 lines (43 loc) · 1.29 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
import { defineConfig } from 'vitest/config';
import { fileURLToPath } from 'node:url';
export default defineConfig({
resolve: {
alias: {
// Map astro:content virtual module to a stub so Vite can resolve it
// during import analysis. Tests then use vi.mock() to override behavior.
'astro:content': fileURLToPath(
new URL('./src/__mocks__/astro-content.ts', import.meta.url),
),
},
},
test: {
// Use happy-dom for DOM simulation (faster than jsdom)
environment: 'happy-dom',
// Include test files
include: ['src/**/*.{test,spec}.{js,ts,jsx,tsx}'],
// Exclude patterns
exclude: [
'node_modules',
'dist-astro',
'e2e',
'spec',
],
// Coverage configuration
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/**/*.{test,spec}.{ts,tsx}',
'src/**/*.d.ts',
'src/**/*.astro',
'src/content/config.ts', // Content collections schema (no logic to test)
'src/__mocks__/**', // Test stubs for virtual modules
],
},
// Test timeout (for slower tests)
testTimeout: 10000,
// Globals (for describe, it, expect without imports)
globals: true,
},
});