MCPInstall

react-testing-library

React Testing Library best practices for writing maintainable, user-centric tests. Use when writing, reviewing, or refactoring RTL tests. Triggers on test files, testing patterns, getBy/queryBy queries, userEvent, waitFor, and component testing.

Installs
404
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/pproenca/dot-skills --skill react-testing-library
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads react-testing-library automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

React Testing Library Best Practices

Comprehensive testing guide for React components using Testing Library, designed for AI agents and LLMs. Contains 43 rules across 9 categories, prioritized by impact to guide test writing and code review.

When to Apply

Reference these guidelines when:

  • Writing new component tests with React Testing Library
  • Selecting queries (getByRole, getByLabelText, etc.)
  • Handling async operations in tests (findBy, waitFor)
  • Simulating user interactions (userEvent)
  • Reviewing tests for anti-patterns and implementation detail testing

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Query SelectionCRITICALquery-
2Async HandlingCRITICALasync-
3Common Anti-PatternsCRITICALanti-
4User InteractionHIGHuser-
5AssertionsHIGHassert-
6Component SetupMEDIUMsetup-
7Test StructureMEDIUMstruct-
8DebuggingLOW-MEDIUMdebug-
9Accessibility TestingLOWa11y-

Quick Reference

1. Query Selection (CRITICAL)

  • query-prefer-role - Prefer getByRole over other queries
  • query-avoid-testid - Avoid getByTestId as primary query
  • query-use-screen - Use screen for queries
  • query-label-text-forms - Use getByLabelText for form fields
  • query-role-name-option - Use name option with getByRole
  • query-get-vs-query - Use getBy for present, queryBy for absent
  • query-within-scope - Use within() to scope queries

2. Async Handling (CRITICAL)

  • async-findby-over-waitfor - Use findBy instead of waitFor + getBy
  • async-await-findby - Always await findBy queries
  • async-single-assertion-waitfor - Single assertion in waitFor
  • async-no-side-effects-waitfor - Avoid side effects in waitFor
  • async-waitfor-disappear - Use waitForElementToBeRemoved

3. Common Anti-Patterns (CRITICAL)

  • anti-unnecessary-act - Avoid unnecessary act() wrapping
  • anti-manual-cleanup - Remove manual cleanup calls
  • anti-implementation-details - Avoid testing implementation details
  • anti-empty-waitfor - Avoid empty waitFor callbacks
  • anti-container-queries - Avoid using container for queries
  • anti-redundant-roles - Avoid adding redundant ARIA roles

4. User Interaction (HIGH)

  • user-prefer-userevent - Use userEvent over fireEvent
  • user-setup-before-render - Setup userEvent before render
  • user-await-interactions - Always await userEvent interactions
  • user-keyboard-for-special-keys - Use keyboard() for special keys
  • user-clear-before-type - Use clear() before retyping

5. Assertions (HIGH)

  • assert-jest-dom-matchers - Use jest-dom matchers
  • assert-visible-over-in-document - Use toBeVisible() for visibility
  • assert-text-content - Use toHaveTextContent() for text
  • assert-have-value - Use toHaveValue() for inputs
  • assert-accessible-description - Use toHaveAccessibleDescription()

6. Component Setup (MEDIUM)

  • setup-wrapper-providers - Use wrapper option for providers
  • setup-custom-render - Create custom render with providers
  • setup-mock-modules - Mock modules at module level
  • setup-fake-timers - Configure userEvent with fake timers
  • setup-render-hook - Use renderHook for testing hooks

7. Test Structure (MEDIUM)

  • struct-arrange-act-assert - Follow Arrange-Act-Assert pattern
  • struct-one-behavior-per-test - Test one behavior per test
  • struct-descriptive-names - Use descriptive test names
  • struct-avoid-beforeeach-render - Avoid render() in beforeEach

8. Debugging (LOW-MEDIUM)

  • debug-screen-debug - Use screen.debug() to inspect DOM
  • debug-logroles - Use logRoles to find available roles
  • debug-testing-playground - Use Testing Playground for queries

9. Accessibility Testing (LOW)

  • a11y-role-queries-verify - Role queries verify accessibility
  • a11y-verify-focus - Test focus management
  • a11y-test-aria-states - Test ARIA states and properties

How to Use

Read individual reference files for detailed explanations and code examples:

  • Section definitions - Category structure and impact levels
  • Rule template - Template for adding new rules

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules
metadata.jsonVersion and reference information

FAQ

What does the react-testing-library skill do?

React Testing Library best practices for writing maintainable, user-centric tests. Use when writing, reviewing, or refactoring RTL tests. Triggers on test files, testing patterns, getBy/queryBy queries, userEvent, waitFor, and component testing.

How do I install react-testing-library?

Run npx skills add https://github.com/pproenca/dot-skills --skill react-testing-library in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/react-testing-library/ (personal) or .claude/skills/react-testing-library/ (project).

Which AI agents can use react-testing-library?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is react-testing-library safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains react-testing-library?

It is published by pproenca in pproenca/dot-skills. It has 404 recorded installs.

More from pproenca/dot-skills

View all →

zod

pproenca/dot-skills

Zod schema validation best practices for type safety, parsing, and error handling. This skill should be used when defining z.object schemas, using z.string validations, safeParse, or z.infer. This skill does NOT cover React Hook Form integration patterns (use react-hook-form skill) or OpenAPI client generation (use orval skill).

Frontend & Design7.1K installs

vitest

pproenca/dot-skills

Vitest testing framework patterns for test setup, async testing, mocking with vi., snapshots, and test performance (formerly test-vitest). This skill should be used when writing or debugging Vitest tests. This skill does NOT cover TDD methodology (use test-tdd skill), API mocking with MSW (use test-msw skill), or Jest-specific APIs.

Testing & QA6.2K installs

react-hook-form

pproenca/dot-skills

React Hook Form performance optimization for client-side form validation using useForm, useWatch, useController, useFieldArray, the subscribe() API, and the Watch / FormStateSubscribe / FieldArray render-prop components. Covers RHF 7.82 additions including resetDefaultValues() and the disabled field-array option. This skill should be used when building client-side controlled forms with React Hook Form library. This skill does NOT cover React 19 Server Actions, useActionState, or server-side form handling (use react-19 skill for those).

emilkowal-animations

pproenca/dot-skills

Emil Kowalski's animation best practices for web interfaces. Use when writing, reviewing, or implementing animations in React, CSS, or Framer Motion. Triggers on tasks involving transitions, easing, gestures, toasts, drawers, or motion.

Frontend & Design2.8K installs

nuqs

pproenca/dot-skills

nuqs (type-safe URL query state) best practices for Next.js and other React frameworks. This skill should be used when writing, reviewing, or refactoring code that uses nuqs for URL state management. Triggers on tasks involving useQueryState, useQueryStates, search params, URL state, query parameters, nuqs parsers, limitUrlUpdates, Standard Schema, NuqsAdapter, or Next.js routing with state.

Frontend & Design2.3K installs

clean-architecture

pproenca/dot-skills

Clean Architecture principles and best practices from Robert C. Martin's book. This skill should be used when designing software systems, reviewing code structure, or refactoring applications to achieve better separation of concerns. Triggers on tasks involving layers, boundaries, dependency direction, entities, use cases, or system architecture.

Popular testing & qa skills

View category →

tdd

mattpocock/skills

Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.

Testing & QA1.2M installs

grilling

mattpocock/skills

Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.

Testing & QA996.2K installs

migrate-to-shoehorn

mattpocock/skills

Migrate test files from as type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace as in tests, or needs partial test data.

Testing & QA484.1K installs

run-train

lllllllama/rigorpilot-skills

Rigor Train skill for deep learning research repositories. Use when a documented or selected training command should be run conservatively for startup verification, short-run verification, full kickoff, or resume, with command, config, seed, log, checkpoint, status, and metric evidence written to standardized trainoutputs/. Do not use for environment setup, exploratory sweeps, speculative idea implementation, or end-to-end orchestration.

Testing & QA337.8K installs

test-driven-development

obra/superpowers

Use when implementing any feature or bugfix, before writing implementation code

Testing & QA261.8K installs

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

Testing & QA216.8K installs