Test Coverage Analysis
> **Skill Purpose:** Analyze test coverage, enforce thresholds, and report coverage gaps for code quality gates.
SKILL.md
Full skill instructions
Test Coverage Analysis
Skill Purpose: Analyze test coverage, enforce thresholds, and report coverage gaps for code quality gates.
Core Skill Pattern
Objective: Maintain measurable test coverage and prevent regressions in critical areas.
Universal Pattern:
- Define coverage thresholds by scope
- Collect coverage on CI and locally
- Generate HTML/JSON reports
- Identify hot spots and low coverage areas
- Track coverage changes over time
Key Decisions (Project-Specific):
- Global vs per-package thresholds
- Branch vs line coverage weighting
- Exclusions for generated or vendor code
- Coverage artifacts retention
Project-Specific Implementation Notes
Customize per project:
- Decide minimum coverage by module criticality
- Align coverage gates with quality gates
- Store coverage reports as CI artifacts
Example Implementation (Jest)
// jest.config.js
module.exports = {
collectCoverage: true,
collectCoverageFrom: [
'app/**/*.{ts,tsx}',
'lib/**/*.{ts,tsx}',
'!**/*.d.ts',
'!**/node_modules/**'
],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
}
},
coverageReporters: ['text', 'json', 'html']
};
Best Practices
- Gate merges on coverage thresholds
- Track coverage deltas per PR
- Prioritize coverage in high-risk areas
- Avoid gaming coverage with low-value tests
- Keep exclusions explicit and minimal
Stop Conditions
STOP and escalate if:
- Coverage thresholds are undefined
- Reports are missing on CI
- Coverage excludes critical modules
Skill Version: 1.0.0
