React Testing Library

Simple and complete React DOM testing utilities that encourage good testing practices.

Library
npm
v16.3.3
19,655 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
64 /100 Good
Development Activity 40
Maintenance 48
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
74 /100 Good
Architecture 75
Code Quality 80
Innovation 65
Learning Curve 75

React Testing Library (@testing-library/react) is a lightweight wrapper around react-dom and react-dom/test-utils (or react-test-renderer for React Native) that provides utilities for rendering React components and querying the resulting DOM the way an actual user would — by text, label, or role — rather than by internal implementation details like component instances or state. It exposes render(), fireEvent, screen (from the shared @testing-library/dom query engine), and renderHook() for testing custom hooks in isolation, plus an automatic cleanup that unmounts components between tests.

The library deliberately avoids exposing shallow rendering or internal component instances, pushing tests toward asserting on rendered output and user-observable behavior — the guiding principle behind the whole Testing Library family (DOM Testing Library, Vue Testing Library, and others). Since v13, it also absorbed the renderHook API previously shipped as the now-deprecated @testing-library/react-hooks package, making it the single canonical package for testing both components and hooks in React.

What You Get

  • render() to mount a React component into a jsdom container and get back query utilities (getByRole, getByText, etc.)
  • screen, exported from @testing-library/dom, for querying the whole rendered document without holding onto a render() result
  • fireEvent (and userEvent, in the companion @testing-library/user-event package) to simulate user interactions
  • renderHook() for testing custom React hooks in isolation, without needing to build a host component
  • Automatic component cleanup between tests plus configuration hooks (configure()) for test-id attribute names and async utility timeouts

Common Use Cases

  • Testing that a component renders expected text, roles, and accessible labels after user interaction
  • Testing custom React hooks (state, effects, context) in isolation via renderHook()
  • Writing integration-style tests for forms, modals, and interactive widgets that assert on DOM output rather than internal state
  • Replacing shallow-rendering-based test suites (e.g. from Enzyme) with behavior-driven, DOM-query-based tests

Under The Hood

Architecture The library’s core (src/pure.js) implements render() by mounting a component into a detached DOM container via react-dom/client’s createRoot (or react-dom for older React versions), wrapping updates in act() (src/act-compat.js handles cross-React-version act compatibility), and returning the container along with query helpers bound to it via @testing-library/dom’s getQueriesForElement; fireEvent (src/fire-event.js) dispatches native DOM events through the same act()-wrapped path so React’s state updates are flushed synchronously in tests.

Tech Stack Plain JavaScript (not TypeScript, though type declarations are hand-maintained under types/), built with kcd-scripts (Kent C. Dodds’ shared build/lint/test tooling), depending on @testing-library/dom for the actual query engine so DOM-querying logic is shared across the whole Testing Library family rather than reimplemented per framework.

Code Quality Extensively tested against its own behavior (src/tests covers render, rerender, cleanup, auto-cleanup, act compatibility, renderHook, error handling, and end-to-end scenarios), with CI-enforced coverage via codecov.yml and a validate script (lint + typecheck + test) gating changes — appropriate rigor for a library whose job is to be a trustworthy foundation for everyone else’s tests.

API Design The API is intentionally minimal — render, screen, fireEvent, renderHook, cleanup — and consistently steers users toward querying by accessible role/label/text rather than test IDs or component internals, which is the library’s core design philosophy; the tradeoff is that tests requiring instance-level assertions (rare in idiomatic usage) require dropping down to raw DOM APIs.

Used by 196 apps in this directory

TypeScript
98%
AGPL 3.0

Karakeep

Bookmarks Archiving

29,321

Self-hosted bookmark manager that captures links, notes, images, and PDFs with AI tagging, full-text search, and automatic archiving.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
Python
64%
Other

Keep

Automation · Devops · Monitoring

12,359

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
89
Repo Health
79
Technical
66
Dependency
Built with
Python 64%
TypeScript 36%
Updated 2 weeks ago
TypeScript
99%
MIT

KeystoneJS

CMS · Developer Tools

9,982

The superpowered headless CMS for developers built with GraphQL and React

View details
92
Repo Health
81
Technical
64
Dependency
Built with
TypeScript 99%
Updated 1 weeks ago
TypeScript
98%
Other

Kibana

Analytics · Monitoring

21,301

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
39%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,358

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 39%
JavaScript 27%
Python 25%
Updated 1 weeks ago
Python
69%
MIT

Langflow

AI Agents · AI Development

155,319

Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.

View details
90
Repo Health
85
Technical
65
Dependency
Built with
Python 69%
TypeScript 22%
Updated 1 weeks ago
TypeScript
97%
Other

Langfuse

AI Development · Monitoring

35,117

Open source AI engineering platform for LLM observability, prompt management, evaluation, and debugging — self-host in minutes or use Langfuse Cloud.

View details
92
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
TypeScript
78%
LGPL 3.0

Latitude

AI Agents · Monitoring

4,686

Open-source AI agent monitoring that catches what will break next before your users do.

View details
86
Repo Health
88
Technical
67
Dependency
Built with
TypeScript 78%
Rust 11%
Python 11%
Updated 2 weeks ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,626

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
51
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 3 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers