Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
56 lines (55 loc) · 1.71 KB
/
Copy pathvitest.config.ts
File metadata and controls
56 lines (55 loc) · 1.71 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
import path from 'node:path';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vitest/config';
// #152: coverage thresholds. Global bar is deliberately modest (this repo
// had zero tests before this change) — the CI failure on unmet thresholds
// is the point: it forces coverage to only ever go up as tests are added,
// rather than silently regressing.
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, '.'),
},
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./vitest.setup.ts'],
exclude: ['**/node_modules/**', '**/dist/**', '**/.next/**', '**/tests/e2e/**', '**/*.spec.ts'],
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
// `include` makes v8 report on every matching file, tested or not
// (not just files a test happened to import) — a repo with 2 tested
// files and 0% coverage everywhere else would otherwise show 100%.
include: [
'app/**/*.{ts,tsx}',
'components/**/*.{ts,tsx}',
'hooks/**/*.{ts,tsx}',
'lib/**/*.{ts,tsx}',
],
exclude: [
'node_modules/**',
'.next/**',
'stories/**',
'**/*.stories.tsx',
'**/*.d.ts',
'**/*.config.*',
'components.json',
'**/types/**',
'**/*.types.ts',
],
thresholds: {
statements: 70,
branches: 65,
// Per-directory override: hooks/ carry more business logic per line
// (data fetching, memoized derivations) than average UI code, so
// they're held to a higher bar.
'hooks/**': {
statements: 80,
},
},
},
},
});