On this page
Overview
React Testing Library tests React interfaces through the text, roles, and accessible names users perceive instead of component internals. Its DOM Testing Library queries help tests survive implementation refactors.
Features and best fit
Hands-on tested within the scope below · Content checked:
Key features
Best fit
Before adoption
16.3.3 / macOS, Node.js 24.18.0, isolated npm project with JSDOM 27.0.0
Rendered a counter, clicked it by role and accessible name, and verified the visible output Count 1.
Official sources
- [1]testing-library/react-testing-library README at v16.3.3(2026-10-05)
- [2]React Testing Library official documentation(2026-10-05)
- [3]React Testing Library v16.3.3 source(2026-10-05)
- [4]testing-library/react-testing-library LICENSE at v16.3.3(2026-10-05)
- [5]testing-library/react-testing-library GitHub metadata(2026-10-05)
Supplemental curator note
It fits teams that want React tests anchored in visible roles and interactions. Start with a small state update queried by role and accessible name, avoiding implementation-specific classes or internal state.
Try it in 3 steps
- 1
Create a pinned DOM test environment
This JSDOM 27.0.0 sample requires Node.js 20 or later and npm; React Testing Library 16.3.3 itself supports Node.js 18 or later. Install the pinned packages in a temporary project.
demo=$(mktemp -d "${TMPDIR:-/tmp}/react-testing-library.XXXXXX") && cd "$demo" && npm init -y >/dev/null && npm install --save-exact @testing-library/react@16.3.3 @testing-library/dom@10.4.1 react@19.2.0 react-dom@19.2.0 jsdom@27.0.0 - 2
Write a user interaction check
Find the Count 0 button by role and accessible name, click it, and query Count 1 by role again.
printf '%s\n' 'import {JSDOM} from '\''jsdom'\''' 'const dom=new JSDOM('\''<!doctype html><html><body></body></html>'\'')' 'globalThis.window=dom.window;globalThis.document=dom.window.document' 'Object.defineProperty(globalThis,'\''navigator'\'',{value:dom.window.navigator,configurable:true})' 'globalThis.HTMLElement=dom.window.HTMLElement;globalThis.Node=dom.window.Node' 'const React=await import('\''react'\'')' 'const {render,screen,fireEvent,cleanup}=await import('\''@testing-library/react'\'')' 'function Counter(){const [count,setCount]=React.useState(0);return React.createElement('\''button'\'',{onClick:()=>setCount(n=>n+1)},`Count ${count}`)}' 'render(React.createElement(Counter))' 'fireEvent.click(screen.getByRole('\''button'\'',{name:'\''Count 0'\''}))' 'console.log(screen.getByRole('\''button'\'',{name:'\''Count 1'\''}).textContent)' 'cleanup()' > demo.mjs - 3
Verify the visible update
Run under JSDOM in Node.js and require the user-visible button text to update to Count 1.
test "$(node demo.mjs)" = "Count 1"
Growth
Growth trends · Last 30 days
19,660 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 0
- Open PRs
- 19
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- reactjs
- testing
- javascript
- Stars
- 19,660
- Forks
- 1,169
- Watchers
- 143
- Open issues
- 63
- Contributors
- 168
- Owner type
- Organization
- Primary language
- JavaScript
- License
- MIT
- Repository last updated
- Aug 27, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Next.js143,179 Stars
2 shared tag(s) · Same language
combine React routing, rendering, and server capabilities for full-stack web applications
JavaScript - Emotion18,019 Stars
2 shared tag(s) · Same language
high-performance CSS-in-JS for React with object/string styles, composition, theming, and runtime caching
JavaScript - PLANKA12,603 Stars
2 shared tag(s) · Same language
Share boards, lists, cards, comments, and attachments in a realtime self-hosted Kanban/project tracker
JavaScript - react-i18next10,051 Stars
2 shared tag(s) · Same language
official React binding that connects i18next resources to components through useTranslation, Trans, providers, and SSR helpers
JavaScript - Carbon Design System9,521 Stars
2 shared tag(s) · Same language
share React components, Sass styles, design tokens, and icons to build product interfaces aligned with IBM Design Language
JavaScript - Onsen UI8,854 Stars
2 shared tag(s) · Same language
build iOS- and Android-style interfaces from shared HTML and JavaScript with Web Components
JavaScript
Report incorrect information
Tell us if any listing information is incorrect or outdated.