Skip to content

Add coverage thresholds and a coverage script to the Jest configuration and CI #304

Description

@mikewheeleer

Enforce a coverage threshold in Jest and run it in CI

Description

jest.config.js sets collectCoverageFrom but defines no coverageThreshold, and package.json has no test:coverage script — so the "95% coverage" expectation every issue references is never machine-enforced. The CI in .github/workflows/ci.yml runs npm test without coverage gating. This issue makes the coverage bar real.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-frontend only.
  • Add a coverageThreshold (global) to jest.config.js at a realistic starting bar (document the chosen numbers and a path to 95%), so coverage regressions fail the suite.
  • Add a test:coverage script to package.json (jest --coverage) and ensure collectCoverageFrom excludes type-only and config files appropriately.
  • Update .github/workflows/ci.yml to run the coverage script (or npm test -- --coverage) so PRs are gated.
  • Do not lower coverage for any currently well-tested module; pick thresholds that pass on main today and document how to raise them.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/tooling-23-coverage-threshold
  • Implement changes
    • Write code in: jest.config.js, package.json, and .github/workflows/ci.yml.
    • Write comprehensive tests in: n/a — verify by running coverage locally and confirming the gate trips when coverage drops.
    • Add documentation: document the coverage policy and how to raise thresholds in README.md.
    • Add comments in the Jest config explaining the threshold choice.
    • Validate the threshold passes on a clean main checkout.
  • Test and commit

Test and commit

  • Run npm run lint, npm run test:coverage, and npm run build.
  • Cover edge cases: threshold passes today, a deliberately untested file trips the gate, and CI runs coverage.
  • Include the coverage summary and CI snippet in the PR description.

Example commit message

test: enforce Jest coverage thresholds and gate them in CI

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions