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

JavaScript
92%
Other

OpenSign

Digital Signiture

7,036

Self-host a full-featured DocuSign alternative with unlimited e-signatures, multi-signer workflows, and cryptographic PDF signing.

View details
79
Repo Health
61
Technical
70
Dependency
Built with
JavaScript 92%
Updated 1 months ago
Python
75%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

38,819

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 75%
Rust 12%
Updated 1 weeks ago
Elixir
55%
Other

Operately

AI Assistants · Collaboration · Productivity

561

The open source company operating system that unifies OKRs, projects, and team execution with built-in accountability cadences.

View details
85
Repo Health
80
Technical
73
Dependency
Built with
Elixir 55%
TypeScript 43%
Updated 1 weeks ago
TypeScript
55%
MIT

optio

AI Agents · AI Code Assistants

1,054

Self-hosted AI agent workflow orchestration that runs on your Kubernetes cluster — from ticket intake to squash-merged PR, entirely within your infrastructure.

View details
80
Repo Health
81
Technical
70
Dependency
Built with
TypeScript 55%
Kotlin 32%
Swift 12%
Updated 1 weeks ago
TypeScript
95%
MIT

Orca

AI Agents · AI Code Assistants

79,834

An open-source Agent Development Environment that orchestrates fleets of parallel AI coding agents — Claude Code, Codex, Gemini and more — each running in its own isolated git worktree.

View details
84
Repo Health
85
Technical
80
Dependency
Built with
TypeScript 95%
Updated 1 weeks ago
Python
63%
Apache 2.0

otari

AI Development · Developer Tools

494

A self-hosted, OpenAI-compatible LLM gateway that puts one endpoint in front of 40+ providers, with virtual API keys, per-user budgets enforced before spend, and full usage tracking.

View details
81
Repo Health
88
Technical
77
Dependency
Built with
Python 63%
TypeScript 35%
Updated 1 weeks ago
JavaScript
64%
AGPL 3.0

overleaf

Collaboration · Productivity

18,188

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
87
Repo Health
80
Technical
62
Dependency
Built with
JavaScript 64%
TypeScript 30%
Updated 3 weeks ago
TypeScript
98%
AGPL 3.0

paseo

AI Agents · AI Code Assistants

18,731

One unified interface to orchestrate Claude Code, Codex, Copilot, OpenCode, and Pi agents in parallel from desktop, mobile, or the terminal.

View details
88
Repo Health
83
Technical
69
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
96%
MIT

Payload CMS

Blogging · CMS · Developer Tools

44,995

The open-source, Next.js-native headless CMS that lives inside your /app folder and gives you a full TypeScript backend instantly.

View details
91
Repo Health
88
Technical
65
Dependency
Built with
TypeScript 96%
Updated 1 weeks 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