Skip to content

Enable Vitest coverage in CI

Problem

Coverage thresholds are configured only in packages/portable-text and packages/widget-renderers (vitest.config.ts). The apps run hundreds of tests but real line coverage is unknown:

  • apps/cms/vitest.config.ts and apps/lms/vitest.config.ts have no coverage block.
  • CI (.github/workflows/ci.yml) runs turbo run test without coverage flags.
  • @vitest/coverage-v8 is already hoisted at the root package.json, and turbo.json's test task already declares coverage/** outputs.

Proposal

  1. Add a coverage block to both apps' vitest.config.ts:
    coverage: {
      provider: 'v8',
      reporter: ['text', 'json-summary', 'html'],
      reportsDirectory: './coverage',
      include: ['src/**/*.{ts,tsx}'],
      exclude: [
        'src/**/*.test.{ts,tsx}',
        'src/**/__tests__/**',
        'src/**/*.d.ts',
        'src/types/**',
      ],
      // thresholds intentionally omitted in first pass
    }
    
  2. Add an npm script test:coverage to each app (CMS already has one; align flags/output dir).
  3. Update CI to run npm run test:coverage (or turbo run test:coverage) on PRs and upload coverage/ as a GitHub Actions artifact for both apps.
  4. Document the baseline coverage numbers in this ticket's notes once first run completes.
  5. Follow-up (not part of this ticket): ratchet to 70% lines per app after baseline is known.

Acceptance criteria

  • Both apps emit coverage/coverage-summary.json after test:coverage.
  • CI artifact contains coverage for cms and lms.
  • No thresholds enforced yet; first baseline numbers recorded in the notes log below.
  • npm run check passes.

Out of scope

  • Threshold enforcement (separate follow-up ticket once baselines are known).
  • Coverage upload to a third-party service (e.g. Codecov).
  • Mutation testing or branch coverage tuning.

Notes / decisions log

  • 2026-05-24: Ticket created from monorepo audit.
  • 2026-05-25: Implemented baseline coverage for apps and packages. CI runs turbo run test:coverage and uploads artifact vitest-coverage. Package thresholds (85% on portable-text / widget-renderers) removed until a ratchet follow-up; local test:coverage reports only.
  • 2026-05-25: Baseline (local turbo run test:coverage, Node 22):
    • lms: lines 42.46%, branches 35.29%
    • cms: lines 48.03%, branches 37.69%
    • portable-text: lines 96.9%, branches 90.62%
    • widget-renderers: lines 87.44%, branches 76.81%
    • widget-wire-schemas: lines 88.37%, branches 0%
    • design-tokens: lines 0% (CSS-only package; no instrumentable TS under src/ beyond tests)