react-testing-library

Test React components with accessible queries and user event simulation.

Updated May 6, 2026
One-click install
npx skills add https://github.com/franzosterkamp/card2contact --skill react-testing-library-franzosterkamp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-testing-library
Source: https://github.com/franzosterkamp/card2contact/tree/main/.agents/skills/react-testing-library
Command: npx skills add https://github.com/franzosterkamp/card2contact --skill react-testing-library-franzosterkamp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @testing-library/react, @testing-library/user-event, @testing-library/jest-dom, and includes scripts (resource) and references (resource) components.

What problem does it solve?

It simplifies testing React components by focusing on user interactions and accessible elements, reducing reliance on internal implementation details.

Core Features & Use Cases

  • Accessible Querying: Enables tests to locate elements by roles, labels, and text, reflecting real user experiences.
  • Async Utilities: Provides functions like findBy and waitFor to handle asynchronous rendering scenarios.
  • Use Case: Test a login form by simulating user typing, clicking, and verifying welcome message display without touching internal state.

Quick Start

Use the react-testing-library to render components, query elements by role, and simulate user events for behavior-driven testing.

Frequently Asked Questions about react-testing-library

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test React components without relying on internal state?

Test React components by querying accessible elements like roles and labels to validate behavior. This approach simulates real user interactions, reducing reliance on internal implementation details.

What is the best way to simulate user events in React component testing?

The best way to simulate user events in React component testing is using user-event utilities. This allows you to replicate behaviors like typing and clicking to validate component interactions in a user-centric workflow.

How do I handle asynchronous rendering when testing React components?

Handle asynchronous rendering in React component testing using async utilities like findBy and waitFor. These functions ensure tests wait for elements to appear, improving test reliability for dynamic UI updates.

Do I need @testing-library/react to query elements by accessible roles?

Yes, @testing-library/react is required to render components and query elements by accessible roles. It provides the accessible querying functions necessary for behavior-driven testing.

Why does testing React components by test IDs reduce test maintainability?

Testing by test IDs reduces maintainability because it couples tests to internal DOM structure. Querying by accessible roles and labels instead reflects real user experiences, improving test reliability and maintainability.