/test-coverage
Jest · Vitest · Playwright
All frameworks
Writes tests
Terminal window
A comprehensive test coverage audit that runs your coverage tool, maps every untested code path by risk, writes the missing tests using your existing framework and patterns, and optionally enforces coverage thresholds. It doesn’t introduce new libraries — it works entirely within what you already have set up.
/test-coverageTo generate the coverage report without writing any tests:
/test-coverage audit onlyTo run a specific subset of phases:
/test-coverage --phase 1-4What it does
Section titled “What it does”| Phase | What Claude does |
|---|---|
| 1 — Setup discovery | Identifies test runner (Jest/Vitest/Playwright), config file, coverage provider, file conventions, and all existing test files |
| 2 — Run coverage | Runs jest --coverage or vitest run --coverage, parses the JSON summary, maps every uncovered line and branch per file |
| 3 — Map untested paths | For each source file: happy path, error paths, every conditional branch, edge cases (null/empty/zero), async rejections, guard clauses, side effects |
| 4 — Prioritise | Ranks gaps as P0 (auth/payment/mutations), P1 (utilities/API handlers/validation), P2 (UI components), P3 (trivial/presentational) |
| 5 — Write unit tests | Writes P0 and P1 tests following your existing patterns — Arrange/Act/Assert, real assertions not mock assertions, no new libraries |
| 6 — Write integration tests | If an integration suite exists, adds endpoint tests: valid input, invalid input, missing auth, ownership enforcement |
| 7 — Write component tests | If a component test suite exists, adds tests for conditional rendering, interactions, and prop variations |
| 8 — Generate report | Produces test-coverage-YYYY-MM-DD.md with before/after coverage, gaps addressed, remaining gaps, and infrastructure recommendations |
| 9 — Enforce thresholds | If no coverageThreshold is configured, adds a safe floor (5% below current level) as a commented-out block in the test config |
Report generated
Section titled “Report generated”test-coverage-YYYY-MM-DD.md — created in the current directory (not committed)
# Test Coverage ReportDate | Test runner | Coverage before → after
## Summary## Files with zero tests## Coverage gaps addressed (file / path / test written / priority)## Remaining gaps (P2/P3 — not auto-written)## RecommendationsWhat gets written automatically
Section titled “What gets written automatically”Auto-written (P0 and P1 gaps):
- Unit tests for every auth/payment/mutation code path
- Unit tests for all utility and pure functions
- Unit tests for API route handlers (happy path + error path)
- Unit tests for form validation logic and data transformations
- Integration tests for untested endpoints (if integration suite exists)
- Component tests for untested conditional rendering and interactions (if component suite exists)
Flagged with recommendation (not auto-written):
- P2/P3 gaps (trivial getters, pure presentational components)
- Tests that would require creating a new test infrastructure from scratch
- Test coverage for third-party library wrappers with no added logic
Standards enforced
Section titled “Standards enforced”Every test written by this command follows these rules:
- Uses your existing framework — no new
npm installor library introductions - Follows your file convention — co-located
*.test.ts,__tests__/, ortests/root, matching what’s already there - Uses your existing mocks —
jest.mock,vi.mock,__mocks__/, MSW — whichever pattern is already in use - Tests behaviour, not implementation — asserts observable output, not that a specific private method was called
- Human-readable test names —
it("returns null when the user has no active subscription")notit("works") - No real network calls — all external dependencies (database, API, email) are mocked
Framework support
Section titled “Framework support”| Test runner | Notes |
|---|---|
| Jest | ✅ Full support — jest --coverage, jest.config.ts, jest.config.js |
| Vitest | ✅ Full support — vitest run --coverage, vitest.config.ts |
| Playwright (API testing) | ✅ Integration tests for API endpoints |
| Cypress | ✅ Component tests and API tests if suite exists |
| Testing Library | ✅ Used for React/Vue/Svelte component tests |
| No test runner set up | ⚠ Claude will identify the gaps and recommend a setup — it will not auto-configure a test runner from scratch |
Install
Section titled “Install”git clone https://github.com/Oladiman/iron-scrolls.gitcd iron-scrollsbash install.sh