react-testing-library

v2026.09.24

React Testing Library mechanics for testing React components and hooks — query selection, async handling, user interaction, assertions, provider setup, and the anti-patterns that make tests brittle. Use for any test that renders a React component or a hook, including choosing between getBy/queryBy/findBy, userEvent flows, waitFor usage, renderHook, custom render wrappers, and reviewing RTL tests for implementation-detail assertions.

GitHub
Install command
npx skhub add shipshitdev/react-testing-library
Markdown
SKILL.md

React Testing Library Best Practices

43 rules across 9 categories for testing React components with Testing Library, prioritized by impact to guide test writing and code review.

Scope

This skill owns React component and hook testing mechanics. For framework-agnostic questions — which level a behavior belongs at, what a coverage number means, how to choose test data, how to kill a flake — use testing-expert.

When to Apply

  • 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)

2. Async Handling (CRITICAL)

3. Common Anti-Patterns (CRITICAL)

4. User Interaction (HIGH)

5. Assertions (HIGH)

6. Component Setup (MEDIUM)

7. Test Structure (MEDIUM)

8. Debugging (LOW-MEDIUM)

9. Accessibility Testing (LOW)

How to Use

Read individual reference files for detailed explanations and code examples:

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules
Discovery
Tags

No tags published for this skill.

Version
Latest version metadata

Version

v2026.09.24

Published

Sep 24, 2026

Category

Uncategorized

License

Not specified

Source path

skills/react-testing-library

Default branch

master

Latest commit

a0f9899

Tree SHA

f05942e