Frontend Test Coverage Improvements
Status: Requested
Repository: arda-frontend-app
Source analysis: Post-mortem on the coverage-80pct project
Context
Section titled “Context”The coverage-80pct project ran three parallel phases using agent teams and worktree isolation, writing 969 tests to bring statement coverage from 66.75% to 85.05%. This document captures improvements identified during that project’s retrospective.
What Worked
Section titled “What Worked”- Three-phase parallel worktree model with zero merge conflicts across 10 agent-slots.
- Phase gates with threshold ratcheting prevented coverage regression.
- Scenario-specific mock strategy (per-describe blocks for loading/empty/error/auth states) was the primary driver for coverage above 50%.
- Uncovered-lines reports with explicit line ranges gave agents precise targets.
Improvements Approved for Implementation
Section titled “Improvements Approved for Implementation”P0 — Do Before Next Coverage Project
Section titled “P0 — Do Before Next Coverage Project”Dead code pre-scan (5.1)
Before assigning files to agents, run a static analysis pass to identify structurally unreachable code. Flag these in the uncovered-lines report so agents skip them immediately. Prevents false expectations about achievable coverage (e.g., itemCard.tsx capped at 48% due to unreachable ComboboxSelect code).
Ban “no crash” assertions (5.2)
Add to agent prompts: every test must verify either a specific behavior change, a mock function call with specific arguments, or a DOM state change. expect(screen.getByText('some text')).toBeInTheDocument() as a sole assertion is prohibited.
Replace conditional test-body guards (5.3)
Ban if (element) { fireEvent.click(element); expect(...) } patterns. Replace with hard assertions (screen.getByRole(...)) that fail loudly when preconditions are not met.
P1 — Next Coverage Project
Section titled “P1 — Next Coverage Project”Size agents by source lines, not file count (5.4) When planning phases, sum total lines of code across assigned files per agent and target roughly equal totals. A 2,700-line file should be the sole assignment for one agent, not paired with other work.
Shared typeahead test factory (5.5)
Extract the DepartmentTypeahead test template into a reusable factory function at src/test-utils/typeahead-test-factory.tsx. Each typeahead test file becomes ~10 lines: import factory, configure, run. Reduces ~1,500 lines of near-duplicate test code to ~300 lines.
Assertion feasibility check (5.6)
Before writing tests, agents verify: Can the assertion be made in JSDOM? Are there duplicate text elements that make getByText ambiguous? Does the component use portals or iframes? A 5-minute checklist prevents tests that must be removed at gates.
P2 — Backlog
Section titled “P2 — Backlog”Automate uncovered-lines reports (5.9)
Script the pre-phase uncovered-lines report generation from jest --coverage --json output. Currently done manually by the team lead before each phase.
Coverage efficiency dashboard (5.11) Auto-generate a phase summary after each gate showing tests-per-pp, coverage-per-agent, and time-per-test for calibrating future project planning.
Key Metric
Section titled “Key Metric”Phase A efficiency was 51.5 tests per percentage point of statement coverage gained. Phase B was 112.2 tests/pp (hardest files). Phase C was 48.1 tests/pp (mix of deepening and easy-win files). Mixing easy-win files into every phase maintains efficiency.
Deferred Items
Section titled “Deferred Items”Items 5.6 (feasibility check) and 5.9 (automated reports) are tracked at workspace/projects/ad-hoc/front-end/test-improvements-1/ for a future dedicated project.
Copyright: © Arda Systems 2025-2026, All rights reserved