
Test Coverage
Hit Flows app approval by closing Vitest or Jest gaps until line coverage passes the 80% hard gate—not just a report.
Install
npx skills add https://github.com/cognitedata/builder-skills --skill test-coverageWhat is this skill?
- Enforces an 80% line coverage hard gate for Flows app approval
- Verifies Vitest or Jest plus v8 coverage config before changing code
- Finds uncovered lines and writes or extends tests instead of only auditing
- Ordered multi-step workflow from tooling check through gap fixes
- Scoped to a directory or file via argument, or whole app by default
Adoption & trust: 1k installs on skills.sh; 4 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Agent Browservercel-labs/open-agents
Tddmattpocock/skills
Use My Browserxixu-me/skills
Test Driven Developmentobra/superpowers
Verification Before Completionobra/superpowers
Webapp Testinganthropics/skills
Journey fit
Common Questions / FAQ
Is Test Coverage safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Test Coverage
# Test Coverage Fix Fix test coverage for **$ARGUMENTS** (or the whole app if no argument is given). This skill enforces the **80% line coverage hard gate** required for Flows app approval by finding AND fixing coverage gaps. Work through every step in order. --- ## Step 1 — Verify test framework and coverage tooling Check that the project has a working test framework with coverage configured: ```bash # Check for vitest or jest in package.json grep -E "(vitest|jest)" package.json # Check for coverage configuration cat vitest.config.ts 2>/dev/null || cat vitest.config.js 2>/dev/null || cat jest.config.ts 2>/dev/null || cat jest.config.js 2>/dev/null ``` Verify: - A test framework (Vitest or Jest) is installed and configured - The config file has a `coverage` section (e.g. `coverage: { provider: 'v8', ... }` in vitest.config.ts) - A coverage reporter is configured (at least `text` and `lcov` or `json-summary`) **If coverage tooling is not configured, fix it now:** 1. Install the coverage provider: ```bash pnpm add -D @vitest/coverage-v8 ``` 2. Add the coverage configuration to `vitest.config.ts`. Read the existing config file, then add the `coverage` section inside `test`: ```typescript // vitest.config.ts — minimum coverage configuration to add test: { coverage: { provider: 'v8', reporter: ['text', 'text-summary', 'lcov'], include: ['src/**/*.{ts,tsx}'], exclude: [ 'src/**/*.test.{ts,tsx}', 'src/**/*.spec.{ts,tsx}', 'src/**/vite-env.d.ts', 'src/main.tsx', ], }, } ``` Write the updated config file. If no vitest.config.ts exists at all, create one with the full `defineConfig` wrapper. --- ## Step 2 — Validate coverage scope The 80% threshold applies to **all `.ts` and `.tsx` files** under `src/`, excluding only: - Test files (`*.test.ts`, `*.test.tsx`, `*.spec.ts`, `*.spec.tsx`) - Type declaration files (`vite-env.d.ts`) - The entry point (`main.tsx`) Apps must **not** exclude pages, components, hooks, or other production code from coverage measurement. ```bash # Check what files are excluded from coverage in the config grep -A 20 "exclude" vitest.config.ts 2>/dev/null || grep -A 20 "exclude" vitest.config.js 2>/dev/null # Check for coveragePathIgnorePatterns in jest config grep -A 10 "coveragePathIgnorePatterns\|collectCoverageFrom" jest.config.ts 2>/dev/null ``` **If the config excludes production files, fix it now:** Remove any exclusion that hides production code from coverage measurement. Only test files, type declarations, and the entry point should be excluded. Rewrite the `exclude` array to contain only: ```typescript exclude: [ 'src/**/*.test.{ts,tsx}', 'src/**/*.spec.{ts,tsx}', 'src/**/vite-env.d.ts', 'src/main.tsx', ], ``` Specifically remove any exclusions for: - `src/pages/` or `src/components/` or `src/hooks/` — **NOT allowed** - Specific feature files — **NOT allowed** unless they are generated code - `src/**/*.tsx` (all components) — **NOT allowed**, this hides the majority of the app Write the corrected config file. --- ## Step 3 — Run tests and collect coverage ```bash # Try common coverage commands based on project setup npx vitest run --coverage 2>/dev/null || npx jest --coverage 2>/dev/null || npm test -- --coverage 2>/dev/null ``` Record the coverage summary: - **Statements:** X% - **Branches:** X% - **Functions:** X% - *