Skip to content

Author a testing guide covering Jest setup, mocking, and coverage gates #99

Description

@mikewheeleer

Document the testing conventions, mocking patterns, and coverage thresholds

Description

The repo has a substantial test suite and a jest.config.ts with per-file coverage thresholds (some files locked at 100%), a src/jest.setup.ts polyfill, and established mocking patterns (mocking @/lib/apiClient, next/navigation, matchMedia, clipboard, fake timers), but none of this is documented — contributors must reverse-engineer the conventions from existing tests. This issue writes a testing guide.

Requirements and context

  • Repository scope: Agentpay-Org/Agentpay-frontend only.
  • Create docs/testing.md documenting: running tests, the jsdom setup in src/jest.setup.ts, how to mock apiClient/next/navigation/matchMedia/clipboard, fake-timer usage, and the per-file coverage thresholds in jest.config.ts.
  • Reference real example tests (e.g. src/app/usage/page.test.tsx, src/components/__tests__/ConfirmDialog.test.tsx) as canonical patterns.
  • Explain the 95% coverage expectation and how to add a file to the locked-coverage list.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b docs/docs-testing-guide
  • Implement changes
    • Write code in: create docs/testing.md (docs only).
    • Write comprehensive tests in: not applicable; verify each referenced test file and config path exists.
    • Add documentation: this issue is the documentation; link it from README.md and any CONTRIBUTING guide.
    • Validate every referenced mock target appears in the codebase.
  • Test and commit

Test and commit

  • Run npm run lint, npm test, and npm run build to confirm nothing breaks.
  • Cross-check the documented thresholds against jest.config.ts.
  • Include a note confirming the documented commands run.

Example commit message

docs(testing): add testing guide for setup, mocking, and coverage

Guidelines

  • Accuracy over completeness; align with the actual config and tests.
  • 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 fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions