Back to Skills

test-coverage

MUST be used whenever fixing test coverage for a Flows app to meet the 80% line coverage hard gate. This skill finds AND fixes coverage gaps — it configures tooling, writes missing tests, covers untested paths, and refactors code for testability. It does not just report. Triggers: test coverage, fix tests, write tests, add tests, coverage fix, 80% coverage, coverage gate, missing tests, testability, vitest coverage, jest coverage.

5stars1forksUpdated 6/27/2026

Security Assessment

Safe(100/100)
Security Score100/100

About test-coverage

A remediation workflow for raising and enforcing the 80% line-coverage hard gate that Cognite Flows apps must pass before approval. Rather than only reporting where coverage is thin, the skill actively closes gaps: it configures the test tooling, writes the missing tests, exercises untested code paths, and refactors code for testability when needed. It is meant to be run against a single file or directory passed as an argument, or against the whole app when no argument is supplied.

The work proceeds through ordered steps. First it verifies that a test framework (Vitest or Jest) is installed and that a coverage section exists in the config, installing @vitest/coverage-v8 and adding a v8 coverage block with text and lcov reporters if they are missing. It then validates coverage scope, insisting that all .ts and .tsx files under src/ count toward the threshold and that only test files, type declarations like vite-env.d.ts, and the main.tsx entry point are excluded; exclusions hiding pages, components, or hooks are stripped out. Next it runs the coverage command, records statements, branches, functions, and lines, and fixes any failing tests caused by missing imports, broken mocks, stale snapshots, missing dependencies, or config errors.

Finally it locates production files that lack a corresponding test and writes comprehensive tests for services, hooks, utils, and contexts, while marking pure presentational components, barrel exports, and type-only files as not requiring tests. It applies framework-appropriate patterns, for example renderHook with QueryClientProvider wrappers for hooks and direct function calls for services and utils, covering happy path, error path, empty state, and edge cases. Use it whenever a Flows app is below the coverage gate or when tests need to be added, fixed, or made to pass. It assumes a pnpm-based React/TypeScript project structure.

FAQ

What coverage threshold does this skill enforce?

It enforces an 80% line-coverage hard gate required for Flows app approval. Apps below 80% overall line coverage are flagged as must-fix.

Which test frameworks does it support?

It works with Vitest or Jest. If coverage is not configured it can install @vitest/coverage-v8 and add a v8 coverage block with text, text-summary, and lcov reporters.

Which files are allowed to be excluded from coverage?

Only test files (*.test/*.spec .ts/.tsx), type declarations like vite-env.d.ts, and the main.tsx entry point. Excluding pages, components, hooks, or other production code is not allowed and will be removed.

Does it only report gaps or also fix them?

It fixes them. It configures tooling, repairs failing tests, writes missing tests, covers untested paths, and refactors code for testability rather than just producing a report.

How does it test React hooks?

It uses renderHook from @testing-library/react wrapped with the necessary providers such as QueryClientProvider, testing initial, loading, success, and error states.

Install test-coverage

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill