agentleFS
mark2685mark2685/agent-tools/skills/flow-frontend/frontend-testing/SKILL.md

frontend-testing

Skill0 starsChanged 5 months agoMITView on GitHub

Scaffolds and strengthens flow-frontend tests with Vitest + React Testing Library, asserting rendered DOM through the real UI path, and hands E2E off to Playwright. Use when the user says "add a test", "write tests for this component", "strengthen these tests", "test this hook", or "/frontend-testing".

18 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use backend-code-review, frontend-query-mutation and 3 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • jpoindexterSkill

    backend-code-review

    Review backend code for quality, security, maintainability, and best practices based on established checklist rules. Use when the user requests a review, analysis, or improvement of backend files (e.g., `.py`) under the `api/` directory. Do NOT use for frontend files (e.g., `.tsx`, `.ts`, `.js`). Supports pending-change review, code snippets review, and file-focused review.

    Also in 5 projects that use this

  • lien0219Skill

    frontend-query-mutation

    Guide for implementing Langflow frontend query and mutation patterns with Axios and TanStack React Query v5. Trigger when creating or updating API hooks in controllers/API/queries, consuming UseRequestProcessor in components, deciding whether to use useQuery or useMutation, handling conditional queries, cache invalidation, mutation error handling, or migrating legacy API calls to the query hook pattern.

    Also in 3 projects that use this

  • Charlie85270Skill

    component-refactoring

    Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component --json` shows complexity > 50 or lineCount > 300, when the user asks for code splitting, hook extraction, or complexity reduction, or when `pnpm analyze-component` warns to refactor before testing; avoid for simple/well-structured components, third-party wrappers, or when the user explicitly wants testing without refactoring.

    Also in 4 projects that use this

  • chendongqiSkill

    frontend-code-review

    Trigger when the user requests a review of frontend files (e.g., `.tsx`, `.ts`, `.js`). Support both pending-change reviews and focused file reviews while applying the checklist rules.

    Also in 7 projects that use this

  • etewiahSkill

    e2e-testing

    Playwright E2E testing and Lighthouse performance auditing. Use when setting up E2E tests, running Playwright tests, performing Lighthouse audits, or debugging E2E test failures.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 18 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write or strengthen tests that assert real behavior, not helper output.

    line 8
  2. Very specific:

    Render and assert the DOM: Use render + screen from @testing-library/react and userEvent for interaction.

    line 24
  3. Very specific:

    Cover combinatorial cases with a table: When behavior varies across inputs (variant × disabled, role × feature-flag, empty/one/many), drive …

    line 38
  4. Distinctive:

    Add a canary for silent failures: If a test could pass while the feature is mis-wired (e.g.

    line 43
  5. Very specific:

    Keep cleanup() in afterEach.

    line 68

“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/frontend-testing

Write or strengthen tests that assert real behavior, not helper output. Mock-heavy tests that bypass the UI are near-worthless: the closer a mock sits to the component, the less the test proves. Conventions live in the testing rule (installed at .claude/rules/testing.md) — follow them; this skill is the procedure.

Runs in flow-frontend. Tests are co-located *.test.tsx/*.test.ts files run by Vitest in jsdom. The React plugin varies: the apps use @vitejs/plugin-react-swc, several packages use plain @vitejs/plugin-react — read the target package's vitest.config.ts. One test file per source file. Run a package's suite with pnpm test.

Steps

  1. Identify the unit and its real entry point. For a component, that is rendering it and driving it through user-visible interactions — not calling its internal handlers directly. For a hook, render it inside a host component or renderHook.
  2. Render and assert the DOM. Use render + screen from @testing-library/react and userEvent for interaction. Every test makes at least one positive assertion on rendered output that a user could observe:
    • Query by role/label/text (getByRole, findByText), not test-id, unless the element has no accessible handle.
    • Assert visible state changed (toBeInTheDocument, toBeDisabled, toHaveTextContent), not that an internal function was called.
    • await async UI with findBy*/waitFor; cleanup() in afterEach.
  3. Exercise the real UI path. Click the actual button, type into the actual field, submit the actual form. A test that calls onSubmit(values) directly proves nothing about whether the form wires up. Mock only at true boundaries — the RPC client / server action — never the component's own logic or converters.
  4. Cover combinatorial cases with a table. When behavior varies across inputs (variant × disabled, role × feature-flag, empty/one/many), drive a it.each / describe.each table so the matrix is explicit and readable. Include the edge rows: empty list, single item, error state, loading state.
  5. Add a canary for silent failures. If a test could pass while the feature is mis-wired (e.g. a parity test where both sides read the same stub), add a positive assertion that fails loudly when the wiring breaks. A green suite must mean the feature works.
  6. Hand E2E to Playwright. Vitest covers component and unit behavior. Cross-page flows, auth, real navigation, and business-intent journeys belong in Playwright against the running stack — do not fake them in jsdom. To author those, use the Playwright planner/generator agents; to make them runnable, use the e2e-test-fixture skill.
  7. Run and report. pnpm test (or scope to the package). Report what is covered, which cases the table exercises, and any behavior you deliberately pushed to E2E.

Anti-patterns to reject

  • Asserting a mock was called instead of asserting the rendered result.
  • Testing a converter's output by importing the converter — test it through the component that uses it, or test the converter directly as a pure function, but never mock it inside a component test.
  • A snapshot as the only assertion. Snapshots catch nothing intentional; assert specifics.

Gotchas

  • The apps' vitest configs use @vitejs/plugin-react-swc, not @vitejs/plugin-react. Copying a plugin import from a package config into an app config (or vice versa) silently changes the transform.
  • Keep cleanup() in afterEach. Several packages (primary-nav, flow-auth, connect-server-actions, others) have no global cleanup in their vitest.setup.ts, so omitting it there leaks DOM between tests. Where a global setup does call it (the apps, ui-toolkit), the extra call is idempotent.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.