agentsclimarketplace

Write frontend tests

Skill kennguyen887/agent-foundation/skills/write-frontend-tests

Claude Code skills marketplace — backend & frontend engineering conventions + step-by-step third-party integration recipes: Stripe, Rapyd, CyberSource, UOB & wallet payments, Singpass/Keycloak OIDC & 3-D Secure, Twilio SMS, Docker & CI/CD. NestJS/TypeScript + React, language-flexible.

Install
npx -y skills add kennguyen887/agent-foundation --skill write-frontend-tests

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Use when writing frontend tests — a test-worthiness gate first (no 1:1 per-file test mirroring), then Jest + React Testing Library for components/hooks/utils that earn a test, and Cypress + Cucumber for e2e user flows. Where tests live, what to test, mocking the router, and the lint/type/test gates. React/Next.js reference.

SKILL.md

3.8 KB, as published. Nobody here has run it

Write frontend tests

Two layers; pick by what you're verifying. principle → ▸ Example (Jest/RTL/Cypress)▸ Other stacks.

LayerToolFor
Unit / componentJest + React Testing Libraryutils, hooks, component behavior in isolation
E2ECypress + Cucumber (BDD)real user flows through the running app

0. Gate — does this deserve a test? (test behaviors, not files)

A suite maps to behaviors/contracts, not the file tree. Never create a test file 1:1 with a source file by default — per-util mirror tests (foo.utils.tsfoo.utils.test.ts) bury real failures, slow every run, and are maintained forever.

  • Direct util/hook test only when the logic is genuinely complex AND matters (money, dates, parsing, non-trivial business rules) or it pins a regression that actually occurred.
  • Skip it when a component/page/e2e test already exercises the behavior, or the code is trivial glue (mapping, prop plumbing, re-exports) whose breakage is instantly visible in dev.
  • Prefer proving a util through the component that uses it; a separate util test duplicating that coverage is junk. When in doubt → don't write it ("Test only what matters", ~/.claude/CLAUDE.md).

1. Unit / component (Jest + RTL)

  • Colocate *.test.ts(x) next to source (or under src/test/). Test behavior through the public surface: render the component, query by role/text, fire user events, assert what the user sees — not internal state. Pure utils/hooks that pass the §0 gate are tested directly.
  • Mock the framework + externals only: jest.mock('next/router', () => ({ useRouter: () => ({ query: {} }) })), mock service classes; never mock the unit under test.
  • AAA + specific assertions (toEqual/toMatchObject with real expected values, not toBeTruthy()).
    describe('convertObjectToArray', () => {
      it('flattens primitive values', () => {
        expect(convertObjectToArray({ a: 1, b: 'x' })).toEqual(['a', '1', 'b', 'x']);
      });
    });
    
    Other stacks: Vitest + RTL — identical patterns.

2. E2E (Cypress + Cucumber)

  • Gherkin feature files under cypress/e2e/<feature>/*.feature describe flows in Given/When/Then; step definitions implement them; Scenario Outline + Examples cover input variations. Keep API helpers in cypress/services/, test data in cypress/constants/, and custom commands in cypress/support/.
    Scenario: Create a listing
      Given User logged in
      When User submits the new-listing form
      Then The listing appears in the list
    
    Other stacks: Playwright (+ optional BDD) — same user-flow-level coverage.

3. Gates

Lint/format = Biome (warning-first rollout, promoted to errors over time). A git-hook runner (e.g. lefthook) runs biome check/format on staged files pre-commit, and type-check + jest pre-push. Run pnpm test (unit) and the e2e suite before opening a PR.

Verification

  • Important new behavior is covered at the outermost sensible layer (component via RTL; Cypress for a user-facing flow); any direct util/hook test passes the §0 gate — no 1:1 mirror files, no mock-only tests. Tests assert observable behavior with specific values, not truthiness.
  • pnpm type-check, pnpm test, and Biome all pass.

Related

  • structure-a-frontend-app · write-frontend-code · write-unit-tests (backend equivalent).

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.