Test coverage

From LedgerHQ/ledger-live · View interactive version

Test coverage is an AI agent skill from the GitHub repository LedgerHQ/ledger-live. Increase test coverage to 90% on a target zone with iterative writing and refactoring. Use when driving coverage toward 90% in a chosen package or folder.

How to use this skill

Skill file

Test Coverage

Increase test coverage to 90% on a target zone with iterative writing and refactoring.

Prompt Variables

$TARGET_ZONE

Directory path or Jira ticket URL for the zone to cover (e.g., src/mvvm/features/Accounts/ or https://ledgerhq.atlassian.net/browse/LIVE-1234)

Instructions

Follow all conventions from the testing skill (.agents/skills/testing/SKILL.md).

Delegate test execution to the test-runner subagent throughout.

Step 1: Scope and Analyze

  1. If $TARGET_ZONE is a Jira URL, fetch the ticket via Atlassian MCP and extract affected files.
  2. Use code-explorer subagent to analyze the zone: trace execution paths, map dependencies, and identify branching logic worth testing.
  3. Measure current coverage:

```bash

pnpm <mobile|desktop> test:jest --coverage \

--collectCoverageFrom='<zone-glob>' \

--coverageReporters=text-summary

```

  1. From the code-explorer analysis, build the list of files to test. Skip type definitions, barrel re-exports, and thin wrappers with no branching.
  2. For each remaining file, ask:

If all answers are no, skip.

Step 2: Write Tests

Order: pure utils -> hooks -> viewModels -> components with side effects.

For each file:

  1. Search existing mocks/fixtures/factories before creating new ones (see testing skill).
  2. Write tests following all testing skill conventions.
  3. Run tests via test-runner. Fix failures before moving to the next file.

Loop until coverage >= 90%.

Step 3: Refactoring Loop

Three sequential passes. After each pass, run tests via test-runner -- they must still pass before the next pass.

Pass 1 -- Audit mocks

Pass 2 -- Deduplicate

Pass 3 -- Prune redundant tests

Step 4: Summary Report

Output a report covering:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.