Skip to content

Implement test coverage reportingΒ #16

@AJaccP

Description

@AJaccP

Add Vitest coverage reporting so we can see how much of the codebase the tests exercise.


🧠 Context

The project uses Vitest (pnpm test β†’ vitest run). Coverage is not enabled. Vitest has built-in coverage (the equivalent of pytest-cov) via a provider package.

The goal here is reporting only β€” print a coverage summary and generate an HTML report. Do not add an enforced threshold that fails the build. The test suite is still small, so a hard gate would just block PRs; a threshold can be added later once coverage is meaningful.


πŸ› οΈ Implementation Plan

  1. Install the coverage provider: pnpm add -D @vitest/coverage-v8 (the default V8 provider β€” fast, native). This repo has security settings in pnpm-workspace.yaml; if the install is blocked by a policy error, flag it to Jacc rather than working around it.
  2. Add a test:coverage script to package.json: vitest run --coverage.
  3. Configure coverage in vite.config.ts under test.coverage:
    • provider: 'v8'
    • reporter: ['text', 'html'] (terminal summary + an HTML report)
    • sensible excludes: src/main.tsx, **/*.test.ts, config files (*.config.*), type-only files (src/types/**), and the test setup.
    • No thresholds.
  4. Run pnpm test:coverage and confirm it prints a summary table and writes the HTML report.
  5. Add the coverage output directory (e.g. coverage/) to .gitignore. (This also keeps it out of prettier/eslint, which respect .gitignore.)
  6. Before pushing, run pnpm format then pnpm typecheck, pnpm lint, pnpm format:check, and pnpm test β€” CI now gates on all of these, so your vite.config.ts / package.json edits must be formatted.

🚫 Out of scope (stretch / later)

  • Wiring coverage into CI (.github/workflows/ci.yml) and uploading an lcov artifact β€” a reasonable stretch goal, but keep the first PR to local reporting unless you want to take it on.
  • Enforced coverage thresholds β€” stick to report-only for now. We don't want CI immediately breaking.

βœ… Acceptance Criteria

  • pnpm test:coverage runs and prints a coverage summary in the terminal
  • @vitest/coverage-v8 is added as a devDependency
  • test.coverage is configured in vite.config.ts with sensible excludes
  • No enforced threshold (reporting only)
  • The coverage output directory is gitignored
  • pnpm typecheck, pnpm lint, pnpm format:check, and pnpm test all pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions