Skip to content

Commit a15ce67

Browse files
committed
test(build): add coverage thresholds and coverage notes
Add global coverage thresholds to vite.config.ts (80% stmts/lines/funcs, 75% branches) with an explicit exclude list mirroring test.exclude. Add docs/coverage-notes.md documenting known-low files (useBuzzer.ts ~2%, db/index.ts ~46%), the rationale for global-only thresholds, and c8 ignore annotation conventions for untestable callsites.
1 parent 1db520b commit a15ce67

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

docs/coverage-notes.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Coverage Notes
2+
3+
Files with intentionally low coverage, tracked here until their epics are complete.
4+
CI enforces **global** thresholds only — no per-file gates.
5+
6+
## Known-low files
7+
8+
| File | Stmts | Reason | Tracking |
9+
|---|---|---|---|
10+
| `hooks/useBuzzer.ts` | ~2% | Buzzer epic not yet implemented — WebRTC adjudication logic lives here but has no unit-testable surface until the GM control system is wired up | Buzzer epic |
11+
| `db/index.ts` | ~46% | Low-level Dexie helpers; untested paths are legacy migration scaffolding and emergency purge routines that require real IndexedDB environments ||
12+
13+
## Annotation conventions
14+
15+
Use `/* c8 ignore next */` for a single uncovered line:
16+
```ts
17+
/* c8 ignore next */
18+
if (process.env.NODE_ENV === 'test') return
19+
```
20+
21+
Use `/* c8 ignore start */` / `/* c8 ignore stop */` for a block:
22+
```ts
23+
/* c8 ignore start */
24+
// WebRTC teardown — untestable without a real peer connection
25+
peer.destroy()
26+
/* c8 ignore stop */
27+
```
28+
29+
These annotations suppress v8 coverage for those lines so they do not
30+
drag down thresholds. Add a comment explaining *why* the block is excluded.
31+
32+
## Thresholds (vite.config.ts)
33+
34+
| Metric | Threshold |
35+
|---|---|
36+
| Statements | 80% |
37+
| Lines | 80% |
38+
| Functions | 80% |
39+
| Branches | 75% |
40+
41+
Branches are set slightly lower because JSX ternaries and optional chaining
42+
generate branch entries that are rarely all exercised in unit tests.

vite.config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,27 @@ export default defineConfig({
5656
coverage: {
5757
provider: 'v8',
5858
reporter: ['text', 'lcov'],
59+
// Files excluded from coverage entirely (untestable boilerplate,
60+
// entry points, or files covered by e2e rather than unit tests).
61+
exclude: [
62+
'src/main.tsx',
63+
'src/pages/**',
64+
'src/components/AdminLayout.tsx',
65+
'**/*.d.ts',
66+
'vite.config.ts',
67+
'commitlint.config.js',
68+
],
69+
// Global thresholds — CI fails if the whole suite drops below these.
70+
// Per-file thresholds are intentionally omitted: files with known-low
71+
// coverage (useBuzzer.ts, db/index.ts) are annotated with
72+
// /* c8 ignore */ at the untestable callsites and tracked in
73+
// docs/coverage-notes.md until their epics are complete.
74+
thresholds: {
75+
lines: 80,
76+
functions: 80,
77+
branches: 75,
78+
statements: 80,
79+
},
5980
},
6081
},
6182
})

0 commit comments

Comments
 (0)