Files
atomic-design-poc/docs/project/backlog/WP-46-vitest-coverage.md
T
ehoandClaude Opus 4.8 f8cd77a48a feat(test): WP-46 — Vitest coverage (report-only)
Enable coverage via the @angular/build:unit-test builder's first-class options: a
`coverage` configuration on the test target (v8 provider, text-summary/html/lcov,
excludes for specs/stories/contracts/generated client) + `npm run test:coverage`.
Report-only (no thresholds) — visibility first. CI's test step now runs test:coverage
(strict superset: fails on a failing test, never on coverage). Baseline ~71% stmts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 14:23:55 +02:00

2.3 KiB

WP-46 — Vitest coverage (report + thresholds)

Status: done Phase: 8 — platform/DX/showcase Priority: P1

Outcome

Coverage is first-class in the @angular/build:unit-test builder — no separate vitest config needed. Added a coverage configuration to the test target in angular.json (coverage: true, reporters text-summary/html/lcov, excludes for specs/stories/contracts/generated api-client.ts/main.ts/.d.ts) + @vitest/coverage-v8 (pinned to vitest's 4.1.9 to avoid the mixed-version warning). npm run test:coverageng test --configuration coverage. Report-only (no thresholds) per the ponytail default — visibility first. CI's test step now runs test:coverage (a strict superset of npm test: fails on a failing test, never on coverage). Baseline at delivery: ~71% statements / 69% branches / 68% functions / 74% lines. Output dir coverage/ was already git-ignored. Path to enforce later: add coverageThresholds to the config.

Why

Tests run via the @angular/build:unit-test (Vitest) builder but report no coverage — there's no visibility into what the house test rules actually cover. A template/showcase should surface this.

Decisions

  • Step 1 — verify wiring: confirm how coverage is enabled with the Angular unit-test builder (codeCoverage option and/or a vitest config), add @vitest/coverage-v8.
  • npm run test:coverage → text + HTML/lcov report.
  • Report-only first (ponytail: visibility before a blocking gate, like the semgrep job). Threshold focus on the layers the house rules already demand tests for (domain/**, pure combinators, parse* boundaries, reducers), not a blanket global %; exclude stories, the generated api-client.ts, and DTOs/contracts.
  • Wire into ci-local.sh/CI non-blocking, with a documented path to flip on enforcement later.
  • Open choice: report-only vs enforce a minimum now.

Files

  • package.json (test:coverage + dep), coverage config (builder option or vitest config).
  • scripts/ci-local.sh / .github/workflows/ci.yml — non-blocking coverage step.
  • .gitignore — ignore the coverage output dir.

Acceptance criteria

  • npm run test:coverage produces a report (text-summary + HTML/lcov) with sensible excludes.
  • Coverage runs in CI without failing the build (report-only).
  • npm run ci green.