commands/test-coverage.md
Analyze test coverage, identify gaps, and generate missing tests to reach 80%+ coverage.
| Indicator | Coverage Command |
|---|---|
jest.config.* or package.json jest | npx jest --coverage --coverageReporters=json-summary |
vitest.config.* | npx vitest run --coverage |
pytest.ini / pyproject.toml pytest | pytest --cov=src --cov-report=json |
Cargo.toml | cargo llvm-cov --json |
pom.xml with JaCoCo | mvn test jacoco:report |
go.mod | go test -coverprofile=coverage.out ./... |
For each under-covered file, generate tests following this priority:
foo.ts → foo.test.ts (or project convention)test_create_user_with_duplicate_email_returns_409Show before/after comparison:
Coverage Report
──────────────────────────────
File Before After
src/services/auth.ts 45% 88%
src/utils/validation.ts 32% 82%
──────────────────────────────
Overall: 67% 84% PASS: