Skip to content

Add a coverage reporter and a coverage threshold gate to npm test and CI #156

Description

@mikewheeleer

Implement a coverage report and enforce a coverage threshold in CI

Description

The campaign repeatedly asks contributors for "minimum 95 percent test coverage," but npm test in package.json is just npm run build && node --test dist/ — it produces no coverage report, and .github/workflows/ci.yml cannot fail a PR that drops coverage. There is no way to measure or enforce the bar the issues demand. This issue wires up coverage measurement and a CI gate.

Requirements and context

  • Repository scope: Agentpay-Org/Agentpay-backend only.
  • Add coverage to the test run using Node's built-in --experimental-test-coverage (or c8), emitting a summary and a machine-readable report.
  • Add a test:coverage script and a threshold check that fails when total coverage falls below a configured percentage (start at a realistic floor and document the path to 95%).
  • Add a coverage step to .github/workflows/ci.yml that fails the build below threshold and (optionally) uploads the report as an artifact.
  • Keep npm test fast and green; ensure coverage measures src/ not just dist/.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/ci-82-coverage-gate
  • Implement changes
    • Write code in: scripts in package.json, config for the coverage tool, and the coverage step in .github/workflows/ci.yml.
    • Write comprehensive tests in: the existing suite serves as the corpus; ensure it still passes under coverage.
    • Add documentation: document npm run test:coverage and the threshold in README.md.
    • Keep the threshold honest (do not set it above current reality without adding tests).
    • Validate security assumptions: the coverage tool adds no runtime dependency to the production image.
  • Test and commit

Test and commit

  • Run npm run test:coverage, npm test, and npm run lint.
  • Confirm CI fails when coverage is forced below the threshold, then restore.
  • Include the coverage summary in the PR description.

Example commit message

test: add coverage reporting and a ci coverage threshold gate

Guidelines

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

Community & contribution rewards

  • 💬 Join the AgentPay community on Discord for questions, reviews, and faster merges: https://discord.gg/eXvRKkgcv
  • ⭐ 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
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions