Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
54 lines (53 loc) · 1.63 KB
/
Copy pathvitest.config.ts
File metadata and controls
54 lines (53 loc) · 1.63 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
import react from '@vitejs/plugin-react';
import { resolve } from 'node:path';
import { defineConfig } from 'vitest/config';
/**
* Vitest configuration with a hard 100% coverage gate.
*
* Any code under `src` that is reachable in a happy-path environment must be
* covered by tests. Genuinely-unreachable defensive code (e.g. SSR guards,
* `process.exit()` paths) can be exempted with a `v8 ignore` annotation
* accompanied by a one-line reason — never to silence the gate.
*
* The thresholds are enforced by CI, so a PR cannot merge while coverage
* sits below 100% on the activated surface. Playwright e2e specs live in
* `e2e/` and are outside the vitest scope.
*/
export default defineConfig({
plugins: [react()],
// Unit tests render components without Tailwind processing. Override PostCSS
// with an empty inline config so Vite does not auto-load the project
// `postcss.config.mjs`, whose Next.js plugin shorthand Vite cannot parse.
css: {
postcss: {
plugins: [],
},
},
test: {
environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'],
include: ['src/__tests__/**/*.test.{ts,tsx}'],
coverage: {
provider: 'v8',
reporter: ['text', 'text-summary', 'html', 'lcov'],
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/**/*.test.{ts,tsx}',
'src/**/__tests__/**',
'src/types/**', // type-only modules contribute no executable code
],
thresholds: {
lines: 100,
branches: 100,
functions: 100,
statements: 100,
},
all: true,
},
},
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
});