Code coverage analysis and improvement patterns
View on GitHubplugins/aai-testing/skills/coverage-analysis/SKILL.md
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/the-answerai/alphaagent-team/blob/main/plugins/aai-testing/skills/coverage-analysis/SKILL.md -a claude-code --skill coverage-analysisInstallation paths:
.claude/skills/coverage-analysis/# Coverage Analysis Skill
Patterns for analyzing and improving code coverage.
## Coverage Configuration
### Jest Configuration
```typescript
// jest.config.ts
export default {
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.d.ts',
'!src/**/*.test.{ts,tsx}',
'!src/**/__tests__/**',
'!src/**/index.ts',
'!src/types/**'
],
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'html', 'json-summary'],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
},
'./src/services/': {
branches: 90,
functions: 90,
lines: 90
},
'./src/utils/': {
branches: 85,
functions: 85,
lines: 85
}
}
}
```
### NYC (Istanbul) Configuration
```javascript
// .nycrc.json
{
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"include": ["src/**/*.ts"],
"exclude": [
"**/*.test.ts",
"**/*.spec.ts",
"**/test/**",
"**/types/**"
],
"reporter": ["text", "lcov", "html"],
"check-coverage": true,
"branches": 80,
"lines": 80,
"functions": 80,
"statements": 80
}
```
## Coverage Types
### Statement Coverage
```typescript
function calculate(a: number, b: number): number {
const sum = a + b // Line 1 - covered if function called
const product = a * b // Line 2 - covered if function called
return sum + product // Line 3 - covered if function called
}
// 100% statement coverage with one test
test('calculate', () => {
expect(calculate(2, 3)).toBe(11)
})
```
### Branch Coverage
```typescript
function getStatus(score: number): string {
if (score >= 90) { // Branch 1
return 'A'
} else if (score >= 80) { // Branch 2
return 'B'
} else if (score >= 70) { // Branch 3
return 'C'
} else { // Branch 4
return 'F'
}
}
// 100% branch coverage requires 4 tests
test('returns A for 90+', () => expect(getStatus(95)).