React Testing Best Practices Agent Skill

Use when writing, reviewing, or refactoring React component tests with Testing Library.

Context cost
25.6k tokensestimated from the bundle, loaded when it triggers
Bundle
15 files · 110.6 kB3 scripts among them — read before you run
Licence
Apache-2.0the author’s own terms
Last change
—v1.0.0
Servers it uses
Noneruns standalone

What it does

Use when writing, reviewing, or refactoring React component tests with Testing Library. Load when you see render(), screen, fireEvent, userEvent, waitFor, or *.test.tsx files. Covers query priority (getByRole > getByLabelText > getByText), user-centric testing patterns, async utilities, custom renders with providers, and accessibility-first assertions. Keywords include RTL, Testing Library, screen, getByRole, findBy, queryBy, userEvent, waitFor, toBeInTheDocument, testing-library/react, testing-library/user-event, jest-dom.

What this skill changes about the agent has not been set out here as a list. Its SKILL.md, shown below, says it in the author’s own words.

reactrefactoringsecuritytestingwriting

The skill itself

A skill is instructions the model reads, so you can see what you are getting: below is the start of its SKILL.md. The front matter loads with every session, the body loads when the skill triggers, and the whole file comes with the install.

SKILL.md15.2 kB · preview
--- name: accelint-react-testing compatibility: Requires @testing-library/react, works with vitest or jest license: Apache-2.0 metadata: author: accelint version: "1.0.0" ---
11# React Testing Best Practices
12
13Expert guidance for writing maintainable, user-centric React component tests with Testing Library. Focused on query selection, accessibility-first testing, and avoiding implementation details.
14
15## NEVER Do When Writing React Tests
16
17- **NEVER query by test IDs before trying accessible queries** - Test IDs bypass accessibility verification: a button with data-testid="submit" but no accessible name works in tests but fails for screen reader users. When tests pass with test IDs, you ship inaccessible UIs. Query hierarchy: getByRole > getByLabelText > getByText > getByTestId. Each step down this list means less confidence your UI is usable.
18- **NEVER use fireEvent for user interactions when userEvent is available** - fireEvent dispatches single DOM events, missing the event sequence real users trigger: fireEvent.click() fires one click event, but real users trigger focus → mousedown → mouseup → click. Components that work with fireEvent break in production when users interact normally. userEvent.click() simulates the full interaction sequence, catching bugs fireEvent misses.
19- **NEVER test implementation details instead of user behavior** - Tests that verify "state variable X equals Y" or "function Z was called" create false failures: you refactor from useState to useReducer, all tests fail, yet the UI works identically. Testing implementation details punishes refactoring and provides zero confidence the user experience works. Test what users see and do (rendered output, interaction results), not how your component achieves it internally.
20- **NEVER query from container or use destructured queries after initial render** - const { getByText } = render(<Component />) creates stale queries that miss updates: after state changes, destructured queries search the initial DOM snapshot, missing newly rendered elements. This causes "element not found" errors for elements that are actually present. Always use screen.getByText() which automatically queries the current DOM state. Using screen consistently also makes tests more maintainable - adding a new query doesn't require updating the destructuring.
21- **NEVER add aria-label or role attributes solely for tests** - If you're adding aria-label="submit-button" or role="button" just so tests can find elements, you're working backwards. Tests should verify the component is already accessible, not make it accessible for tests. Adding test-only ARIA pollutes production code and masks real accessibility problems. Fix the component's semantic HTML and existing ARIA first.
22- **NEVER snapshot entire component trees without specific assertions** - Massive snapshots with 500+ lines break on any change (updated classname, new prop, reordered elements), forcing reviewers to approve diffs they can't meaningfully evaluate. When test failures require "just update the snapshot" without understanding why, the test has zero value. Snapshot specific critical structures (error messages, data tables) with targeted assertions for everything else.
23- **NEVER use waitFor for actions that return promises** - waitFor(() => expect(element).toBeInTheDocument()) polls repeatedly until timeout when a promise-based findBy query solves it in one shot: await screen.findByText('loaded') waits for the element to appear without polling. Reserve waitFor for assertions that can't use findBy (checking element disappears, waiting for attribute changes).
24- **NEVER perform side effects inside waitFor callback** - waitFor(() => { fireEvent.click(button); expect(text).toBeInTheDocument(); }) runs the click multiple times as waitFor retries, causing unpredictable behavior. waitFor is for waiting on assertions, not triggering actions. Perform all actions outside waitFor, then use waitFor only for the assertion: fireEvent.click(button); await waitFor(() => expect(text).toBeInTheDocument()); or better yet, await userEvent.click(button); expect(await screen.findByText(text)).toBeInTheDocument();.
25- **NEVER create custom renders without documenting provider requirements** - A custom renderWithRedux function with undocumented required store shape breaks for every developer: they call render(<Component />) instead of renderWithRedux(), tests fail with cryptic "Cannot read property of undefined", wasting 15 minutes debugging. Centralize provider setup in test utils with TypeScript types that enforce correct usage, or document required wrappers prominently.
26- **NEVER mix queries from different Testing Library imports** - Importing both @testing-library/react render and @testing-library/dom queries creates confusion: screen from react package doesn't work with getByRole from dom package, causing "screen.getByRole is not a function" errors. Import all queries from @testing-library/react for React components - it re-exports everything from dom with React-specific enhancements.
27
28## Before Writing Tests, Ask
29
This is a preview of SKILL.md. Download or install the skill to get the whole thing.
In the file
SKILL.md2,029 words
Files15
LicenceApache-2.0
Why you can read it

Nothing in a skill executes. The client loads the text and the model follows it, so a skill can be audited the way a runbook is — by reading it.

What it costs in context

Skills are not billed by the call. They are paid for in context: every token the instructions occupy is a token your code, your diff and your conversation cannot use. Here is what this one takes and when it takes it.

≈180
always loaded
The name and description, so the model knows the skill exists and when to reach for it.
25,445
on trigger
The instruction body and 14 supporting files, read only when the skill fires.
12.8%
of a 200k window
Ten skills this size would not fit in the window together.
050k100k150k200k context window

25.6k tokens, estimated from the bundle at four bytes to the token, held for the rest of the session once it triggers. Heavy. Teams tend to install this one per project rather than globally, and load it only when the job comes up.

Servers bill, skills cost

A server charges by the month. A skill charges once per session, in context, and then keeps charging it for as long as the session lives.

Before and after

The same question, put to the same model twice: once as it comes, and once with these instructions loaded.

No worked example has been published for this skill yet.

The procedure it runs

The procedure has not been set out here step by step. It is in the body of its SKILL.md: the start of it is shown above, and the whole file comes with the install.

Prose, not code

These steps are written for a model to follow, not executed by a runtime. It can still be told to skip one, and it will say so when it does.

Servers it uses

None. This skill calls no MCP servers at all.

Everything it needs is in the instructions, so it works in a project with nothing connected — the model reads the file and changes how it works with what it can already reach.

Its SKILL.md does not declare which tools it asks the agent for, so what it touches is whatever the instructions themselves ask for — read them before you install it.

What it asks for
Writes filesnot declared
Network accessnot declared

This SKILL.md carries no allowed-tools line, so neither is declared. A skill grants no permissions of its own — it can only ask for tools your client already has.

What it will not do

Every skill is narrow, and the useful ones say where they stop. These are the jobs this one is the wrong tool for.

What this skill is not for has not been published here. Nothing is implied by that: it is a section the author has not filled in.

What is in the bundle

15 files, 110.6 kB on disk. Mostly text — the instructions the model reads — with 3 scripts in it that your client would run only if the instructions tell it to.

  • SKILL.md15.2 kB
  • AGENTS.md3.3 kB
  • README.md3.5 kB
  • assets/custom-render-template.tsx4.1 kB
  • assets/output-report-template.md10.2 kB
  • references/accessibility-queries.md8.7 kB
  • references/anti-patterns.md12.1 kB
  • references/async-testing.md8.0 kB
  • references/custom-render.md9.4 kB
  • references/query-priority.md7.1 kB
  • references/query-variants.md10.4 kB
  • references/user-events.md10.5 kB
  • scripts/check-query-priority.sh2.5 kB
  • scripts/detect-wrapper-queries.sh3.0 kB
  • scripts/find-fire-event.sh2.6 kB
What is not in it

A skill installs nothing and depends on nothing: it is a folder your client reads. This one carries 3 scripts beside the text, so the bundle is 15 files you can review in full before installing. The Apache-2.0 licence covers the templates and examples as well as the instructions.

Install

Installing copies the bundle into your project. Nothing runs at install time — the files sit on disk until the model reads them.

# React Testing Best Practices · 25.6k tokens when loaded · macOS, Linux mkdir -p .claude/skills && t=$(mktemp -d) && curl -fsSL -o "$t/bundle.tar.gz" https://mcprush.com/api/skills/react-testing-best-practices/bundle.tar.gz && tar -xzf "$t/bundle.tar.gz" -C "$t" && [ -d "$t/react-testing-best-practices" ] && { [ ! -e .claude/skills/react-testing-best-practices ] || { mv .claude/skills/react-testing-best-practices "$t/.previous" && echo "Previous copy moved to $t/.previous"; }; } && mv "$t/react-testing-best-practices" .claude/skills/ && echo "Installed .claude/skills/react-testing-best-practices"
On Windows, or any OS with Node 20+
npx mcprush@latest skill add davidanthonyn/react-testing-best-practices

Windows PowerShell says 'running scripts is disabled on this system'? Run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once, or type npx.cmd instead of npx (codex.cmd, gemini.cmd, grok.cmd likewise). PowerShell 7 needs neither. Writes to .claude/skills/react-testing-best-practices/ in the current project. For every project instead, run mkdir -p ~/.claude/skills && t=$(mktemp -d) && curl -fsSL -o "$t/bundle.tar.gz" https://mcprush.com/api/skills/react-testing-best-practices/bundle.tar.gz && tar -xzf "$t/bundle.tar.gz" -C "$t" && [ -d "$t/react-testing-best-practices" ] && { [ ! -e ~/.claude/skills/react-testing-best-practices ] || { mv ~/.claude/skills/react-testing-best-practices "$t/.previous" && echo "Previous copy moved to $t/.previous"; }; } && mv "$t/react-testing-best-practices" ~/.claude/skills/ && echo "Installed ~/.claude/skills/react-testing-best-practices" (macOS, Linux) — or add --global to the npx line. The curl line replaces .claude/skills/react-testing-best-practices/ only after the download succeeds, so files left there by another skill of the same name, or by an older release, do not mix in. A copy already there is moved aside, not deleted, and the line prints where. It appears as accelint-react-testing in Gemini CLI, Codex, Copilot and Grok (its own name); Claude Code lists it by the folder name, react-testing-best-practices.

Which clients pick it up on their own

A skill is a folder of text. Most of these read a skills folder and pick it up without being told; the rest take the same folder another way — an upload in the app, a parameter on an API call — and then choose it by its description just the same.

Claude Code.claude/skills/
Claude DesktopCustomize › Skills
ChatGPTSkills › Create › Upload
Cursor.cursor/skills/
VS Code.github/skills/
Codex CLI.agents/skills/
Gemini CLI.gemini/skills/
Grok Build.grok/skills/
Microsoft CopilotSkills › Upload a skill
PerplexityComputer › Skills › Upload a skill
DeepSeek Harness.dsh/skills/
Zed.agents/skills/
Devin Desktop.devin/skills/
Windsurf (legacy).windsurf/skills/
OpenAI Agents SDKInstructions or sandbox Skills
HTTP / APIa request parameter
This release
Version1.0.0
Publishedno release date on file
PriceFree
Referencedavidanthonyn/react-testing-best-practices

Versions

v1.0.0 is what is on the shelf; no release here carries a date. Instructions change more often than APIs do — a skill can be rewritten entirely without anything it depends on moving.

v1.0.0
  • No earlier releases have been published to the marketplace.
Pinning

The install command always fetches the release that is current the day you run it — v1.0.0 today — and cannot ask for an earlier one. The copy on your disk does not change until you run it again.

Reviews

—no reviews yet

Nobody has reviewed this skill yet. The rating is the mean of the reviews written here, so there is none until somebody writes the first.

Sign in to review it

A review is tied to an account so it can be answered, edited and taken down by the person who wrote it.

Sign in
Who can post

Anybody with an account, one review each. It carries the version that was current when you wrote it, and the publisher may reply once.

Publisher
Servers0
Claim this skill