react-testing
Skill3 starsChanged 8 months agoMITView on GitHub
Writes and reviews React component tests with Vitest 5, React Testing Library 16, user-event 14, jest-dom 7, and MSW 3: query priority and accessible names, asserting absence, user-event setup, findBy and waitFor rules, act warnings, the Vitest fake-timer hang, cleanup without globals, jsdom gaps, custom renders with providers, renderHook, MSW handlers and error paths, vi.mock and next/navigation, and what async Server Components can and cannot do under RTL. Use when writing, fixing, or reviewing *.test.tsx files, when a test is flaky, hangs, or warns about act, or when the user mentions Testing Library, getByRole, userEvent, waitFor, or MSW. Not for generic false-green test review (gotchas), accessibility audits (wcag-accessibility), or React render speed (react-performance).
19 other projects use a version of this.
Adopted by
Most recently taken up by
- ahmadvahidi/skill-atlastheir own version, first seen Nov 8, 2026
- conjurer-rich/skillstheir own version, first seen Oct 25, 2026
- renepf/claude-skillstheir own version, first seen Oct 25, 2026
- davidanthonyn/claude-skillstheir own version, first seen Oct 20, 2026
- Ronnasayd/aipptheir own version, first seen Oct 20, 2026
- vguedz/skillstheir own version, first seen Oct 17, 2026
Used with
Projects with it also use orch-pipeline, parallel-execution-optimizer and 9 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.
renepfSkillorch-pipeline
Shared orchestration engine for the orch-* skill family. Defines the gated Research-Plan-TDD-Review-Commit pipeline, the size classifier, the agent map, and the two human gates that the orch-* operation skills delegate to. Not usually invoked directly.
Also in 4 projects that use this
marcusgollSkillparallel-execution-optimizer
Identify and execute independent operations in parallel for 3-5x speedup. Auto-analyzes task dependencies, groups into batches, launches parallel Task() calls. Applies to /optimize (5 checks), /ship pre-flight (5 checks), /implement (task batching), /prototype (N screens). Auto-triggers when detecting multiple independent operations in a phase.
Also in 5 projects that use this
ronmkrSkillvite-patterns
Vite build tool patterns including config, plugins, HMR, env variables, proxy setup, SSR, library mode, dependency pre-bundling, and build optimization. Activate when working with vite.config.ts, Vite plugins, or Vite-based projects.
Also in 6 projects that use this
RojiosSkilldefi-amm-security
Security checklist for Solidity AMM contracts, liquidity pools, and swap flows. Covers reentrancy, CEI ordering, donation or inflation attacks, oracle manipulation, slippage, admin controls, and integer math.
Also in 5 projects that use this
renepfSkillprediction-market-oracle-research
Research prediction markets as data sources or oracle signals for products, agents, dashboards, and corporate decision intelligence. Use for source-grounded analysis of market-implied probabilities, caveats, and integration patterns without investment advice.
Also in 3 projects that use this
ronmkrSkillquarkus-security
Quarkus Security best practices for authentication, authorization, JWT/OIDC, RBAC, input validation, CSRF, secrets management, and dependency security.
Also in 4 projects that use this
- +1 more from ronmkr
- +2 more from renepf
Other versions19 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 19
- getsentry/sentry★ 46ksame name
- gongyijie85/dsh-ecc★ 8same name
- nek1987/auto-agent-harness★ 4same name
- aps08/fullstack-clean-architecture★ 2same name
- ronmkr/PromptBook★ 2same name
- conjurer-rich/skills★ 1same name
- diego-tobalina/vibe-coding★ 1same name
- hkarpinen/agent-skills★ 1same name
- NISTALTALSON/essential-claude-skills★ 1same name
- Nupke/react-claude-skills★ 1same name
9 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository17 other files it gives its agents.
- api-securitySkill
- ascii-artSkill
- code-readabilitySkill
- gotchasSkill
- llm-agent-securitySkill
- nextjs-app-routerSkill
- plain-docsSkill
- product-marketingSkill
- prompt-rewriteSkill
- react-performanceSkill
- seoSkill
- spa-performanceSkill
- tailwind-design-systemSkill
- typescript-safetySkill
- ux-copySkill
- wcag-accessibilitySkill
- webgpuSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 19 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 29
Read the component, its existing tests, vitest.config.*, and the setup file.
- Distinctive: line 49
Run the test. Then break the feature on purpose (comment out the handler, return the wrong value) and confirm the test fails.
“Common” is measured: kept by at least 6 in 10 of the 19 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.
Files
React testing
Tests that fail when the feature breaks and pass when it works, whatever the internals look like. Find elements the way a user does, act the way a user does, and wait for what a user would see.
Query by role and name first. If you cannot, the component probably has an accessibility bug.
Mock the edges (network, clock, framework), never your own code.
Versions, source checks, and dates: SOURCES.md.
Procedure
- Read the component, its existing tests,
vitest.config.*, and the setup file. Check the package versions; this skill assumes the stack in SOURCES.md. - Pick what the user does and what they should see as a result. That pair is the test.
- Route by what the test needs, and load only that resource:
writing or fixing a test
|
+-- finding an element, asserting present or absent ...... queries.md
|
+-- clicking, typing, tabbing, uploading .................. user-events.md
|
+-- something appears later, a timer, an act warning ...... async.md
|
+-- config, cleanup, providers, hooks, jsdom crashes ...... setup.md
|
+-- fetch, vi.mock, next/navigation ...................... network-and-mocks.md
|
+-- async page, Server Function, useActionState ........... server-components.md- Run the test. Then break the feature on purpose (comment out the handler, return the wrong value) and confirm the test fails. A test that still passes proves nothing.
Where to read
| Topic | Resource |
Query priority, getBy/queryBy/findBy, role and name, within, absence, screen, text matching, test IDs | queries.md |
userEvent.setup(), forms, keyboard and focus, uploads, clipboard, pointer-events: none, fireEvent cases | user-events.md |
findBy, waitFor rules, waitForElementToBeRemoved, act warnings, fake timers in Vitest | async.md |
Packages, vitest.config.ts, cleanup without globals, jsdom vs browser mode, jsdom gaps, custom render, renderHook, StrictMode | setup.md |
What to mock, MSW 3 setup and error paths, vi.mock and vi.hoisted, next/navigation, spies | network-and-mocks.md |
Async Server Components, Server Functions, useActionState forms, what goes to E2E | server-components.md |
The traps that cost the most time
| Symptom | Cause | Read |
| Every test after a fake-timer test hangs until timeout | vi.useFakeTimers() with defaults: Testing Library only detects Jest's fake timers, so findBy, waitFor, and await user.* wait on a frozen setTimeout | async.md |
Found multiple elements in the second test of a file | Vitest globals is off by default, so RTL's auto cleanup never registered | setup.md |
| An absence check can never fail | expect(queryBy...).toBeDefined(): null is defined | queries.md |
| Assertion runs before the click finished, at random | Missing await on a user-event call | user-events.md |
| Click handler fires twice, or a request is sent repeatedly | Side effect inside a waitFor callback, which retries | async.md |
TypeError: window.matchMedia is not a function | jsdom has no matchMedia, ResizeObserver, IntersectionObserver, scrollIntoView, or dialog.showModal | setup.md |
| Unhandled requests reach the real network after upgrading MSW | MSW 3 renamed onUnhandledRequest to onUnhandledFrame and ignores the old name | network-and-mocks.md |
vi.mock factory says a variable is not defined | vi.mock is hoisted above the file's declarations; use vi.hoisted | network-and-mocks.md |
Async page stays on its Suspense fallback, no error | RTL cannot render async Server Components; await the function or use E2E | server-components.md |
An update to X inside a test was not wrapped in act(...) | A promise or timer settled after the test stopped waiting | async.md |
Review checklist
- Queries use
ByRolewithname, orByLabelText/ByText;ByTestIdonly where no role or text exists - No
roleoraria-*added only for the test - Absence uses
queryBywith.not.toBeInTheDocument(); nothing assertstoBeDefined()on a query userEvent.setup()per test, and every user-event call is awaited- Late content uses
findBy;waitForholds one assertion and no side effects; nosetTimeoutsleeps - Fake timers under Vitest use
shouldAdvanceTime: trueand are restored inafterEach - The setup file imports
@testing-library/jest-dom/vitestand callscleanup(orglobals: true) - The network is mocked with MSW and
onUnhandledFrame: 'error'; the failure path has its own test - No mock of the component, hook, or helper under test
- Assertions check what the user sees or what leaves the component, not internal state
- The test fails when the feature it covers is broken on purpose
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
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.

