From harness-claude
Configures test coverage thresholds in Vitest, interprets coverage reports, and sets quality gates for CI.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:test-coverage-patternsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Configure and interpret test coverage thresholds for meaningful quality signals
Configure and interpret test coverage thresholds for meaningful quality signals
// vitest.config.ts
export default defineConfig({
test: {
coverage: {
provider: 'v8', // or 'istanbul'
reporter: ['text', 'html', 'lcov'],
include: ['src/**/*.ts'],
exclude: ['src/**/*.test.ts', 'src/**/*.d.ts', 'src/**/index.ts'],
},
},
});
Run with: vitest --coverage
coverage: {
thresholds: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
CI fails if coverage drops below these thresholds.
coverage: {
thresholds: {
'src/services/**': { branches: 90, functions: 90, lines: 90, statements: 90 },
'src/utils/**': { branches: 70, functions: 70, lines: 70, statements: 70 },
},
},
if/else, switch, ternary paths takenBranch coverage is the most meaningful metric. A file can have 100% line coverage but miss error-handling branches.
coverage: {
exclude: [
'src/**/*.test.ts',
'src/**/*.stories.ts',
'src/generated/**',
'src/**/index.ts', // barrel files
'src/**/*.d.ts',
'src/main.ts', // entry point
],
},
/* v8 ignore next */ or /* istanbul ignore next */ sparingly for code that cannot be tested:/* v8 ignore next 3 */
if (process.env.NODE_ENV === 'development') {
enableDevTools();
}
vitest --coverage
open coverage/index.html
The HTML report highlights uncovered lines in red and shows branch coverage inline.
// Start low, increase as coverage improves
coverage: {
thresholds: {
lines: 60, // Current: 62% — ratchet up as tests are added
branches: 50, // Current: 53%
},
},
Code coverage measures which lines, branches, and functions your tests exercise. It is a negative indicator — low coverage definitively means undertested code. High coverage does NOT mean well-tested code.
V8 vs Istanbul providers:
Coverage anti-patterns:
Meaningful thresholds by code type:
Coverage in CI:
lcov reporter for SonarQube, Codecov, or Coveralls integrationTrade-offs:
https://vitest.dev/guide/coverage.html
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeChecks and configures code coverage thresholds, reporters, and CI integrations like Codecov for Vitest, Jest, pytest, and Rust projects.
Queries test coverage in Python, Node.js, Rust, Go projects. Identifies uncovered areas/files, analyzes trends, and generates reports before changes or PRs.
Analyzes coverage reports from Jest/nyc, pytest, Go test, JaCoCo to find untested paths, branch gaps, low-coverage files, and suggest targeted tests.