Skip to content

Fix unit test coverage reporting and set realistic thresholds#234

Open
AndyTWF wants to merge 1 commit intomainfrom
fix/unit-test-coverage
Open

Fix unit test coverage reporting and set realistic thresholds#234
AndyTWF wants to merge 1 commit intomainfrom
fix/unit-test-coverage

Conversation

@AndyTWF
Copy link
Copy Markdown
Contributor

@AndyTWF AndyTWF commented Mar 30, 2026

Summary

  • Coverage was broken: V8 only tracked vitest-transformed source files (src/**/*.ts), but oclif's runCommand dynamically loads compiled JS from dist/. Result: ~18% reported coverage despite good test coverage.
  • Fixed by: enabling sourceMap in tsconfig, including dist/src/**/*.js in coverage config, and adding reportOnFailure: true so coverage always reports (even when tests fail).
  • Deleted .nycrc.json: legacy Istanbul/nyc config from the Mocha era, unused since Vitest migration.
  • Set realistic thresholds (60/55/60/60) based on actual coverage as a don't-regress ratchet.

Coverage: 18% → 64% with zero test changes.

Test plan

  • pnpm test:coverage:unit produces a coverage table with ~64% coverage
  • Coverage HTML report is generated in coverage/
  • Thresholds pass (no threshold errors)
  • reportOnFailure: true ensures coverage reports even with pre-existing test failures
  • pnpm exec eslint . passes (0 errors)
  • pnpm test:unit passes (2195 tests, 1 pre-existing failure in spaces/locations/subscribe)

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cli-web-cli Ready Ready Preview, Comment Mar 30, 2026 0:15am

Request Review

Coverage was reporting ~18% because V8 only tracked vitest-transformed
source files, while oclif's runCommand dynamically loads compiled JS
from dist/. Three fixes:

1. Enable sourceMap in tsconfig so V8 can map dist/ back to src/
2. Include dist/src/**/*.js in coverage (where oclif-loaded code lives)
3. Add reportOnFailure: true so coverage reports even when tests fail

Also delete legacy .nycrc.json (unused since Mocha→Vitest migration)
and set thresholds based on actual coverage (60/55/60/60) as a
don't-regress ratchet.

Coverage jumps from 18% → 64% with no test changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant