React Testing Library

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

Library
npm
v16.3.3
19,672 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
61 /100 Good
Development Activity 28
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
93%
AGPL 3.0

CourseLit

Blogging · Ecommerce

1,284

Open-source, self-hosted LMS for selling online courses, digital downloads, and building communities on your own branded website.

View details
63
Repo Health
74
Technical
67
Dependency
Built with
TypeScript 93%
Updated 6 days ago
TypeScript
96%
MIT

deepseek-harness

AI Agents · AI Development · Developer Tools

259,694

An open-source, plugin-based agent harness from DeepSeek AI that runs coding and automation agents across web, desktop, CLI, and SDK surfaces.

View details
82
Repo Health
89
Technical
73
Dependency
Built with
TypeScript 96%
Updated 6 days ago
TypeScript
97%
MIT

DenchClaw

AI Agents · CRM

1,660

An AI-native CRM you self-host on your own machine, built on the OpenClaw agent framework, with a DuckDB backend and pre-built agent skills for managing contacts, deals, reports, and 500+ outreach integrations from natural-language chat.

View details
47
Repo Health
73
Technical
71
Dependency
Built with
TypeScript 97%
Updated 4 months ago
Python
56%
Other

Dify

AI Development · Design Tools · Developer Tools

159,396

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
67
Dependency
Built with
Python 56%
TypeScript 42%
Updated 5 days ago
TypeScript
95%
AGPL 3.0

Docmost

CMS · Collaboration · Note Taking

22,079

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
66
Dependency
Built with
TypeScript 95%
Updated 5 days ago
Python
47%
MIT

Docs

CMS · File Storage

16,942

Open-source collaborative knowledge platform with real-time editing, AI writing tools, and full self-hosting control — built by the French and German governments.

View details
88
Repo Health
81
Technical
68
Dependency
Built with
Python 47%
TypeScript 46%
Updated 6 days ago
TypeScript
88%
MIT

Drawnix

Design Tools · Productivity

14,977

All-in-one open-source whiteboard combining mind maps, flowcharts, and freehand drawing on a single infinite canvas.

View details
60
Repo Health
69
Technical
79
Dependency
Built with
TypeScript 88%
Updated 1 months ago
TypeScript
96%
Other

Dyad

AI Assistants · AI Code Assistants · AI Development

22,046

Build AI-powered apps locally with your own keys, your own models, and zero cloud lock-in.

View details
87
Repo Health
83
Technical
69
Dependency
Built with
TypeScript 96%
Updated 1 weeks ago
Go
47%
Apache 2.0

e2a

AI Agents · Automation

194

Give your AI agents a real, authenticated email address — with SPF/DKIM-verified inbound, HMAC-signed delivery, WebSocket fan-out, and human-in-the-loop approval built in.

View details
79
Repo Health
80
Technical
71
Dependency
Built with
Go 47%
TypeScript 27%
Python 13%
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