Gathering detailed insights and metrics for @testing-library/react-native
Gathering detailed insights and metrics for @testing-library/react-native
Gathering detailed insights and metrics for @testing-library/react-native
Gathering detailed insights and metrics for @testing-library/react-native
@testing-library/jest-native
Custom jest matchers to test the state of React Native
react-native-testing-library
Simple React Native testing utilities helping you write better tests with less effort
@eps1lon/testing-library-react-native
Simple and complete React Native testing utilities that encourage good testing practices.
react-native-testing-mocks
React Native mocks for testing. Same as the internal Jest-based mocks, but decoupled of Jest dependency
🦉 Simple and complete React Native testing utilities that encourage good testing practices.
npm install @testing-library/react-native
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (65.5%)
MDX (31.95%)
JavaScript (1.82%)
CSS (0.74%)
Total Downloads
95,902,858
Last Day
29,055
Last Week
793,562
Last Month
3,501,597
Last Year
39,718,152
MIT License
3,222 Stars
1,109 Commits
276 Forks
29 Watchers
13 Branches
158 Contributors
Updated on Jul 02, 2025
Minified
Minified + Gzipped
Latest Version
13.2.0
Package Id
@testing-library/react-native@13.2.0
Unpacked Size
650.30 kB
Size
141.00 kB
File Count
308
NPM Version
10.5.0
Node Version
20.12.0
Published on
Mar 05, 2025
Cumulative downloads
Total Downloads
Last Day
-9.1%
29,055
Compared to previous day
Last Week
-9.3%
793,562
Compared to previous week
Last Month
1.9%
3,501,597
Compared to previous month
Last Year
49.2%
39,718,152
Compared to previous year
4
4
30
Developer-friendly and complete React Native testing utilities that encourage good testing practices.
You want to write maintainable tests for your React Native components. As a part of this goal, you want your tests to avoid including implementation details of your components and rather focus on making your tests give you the confidence for which they are intended. As part of this, you want your tests to be maintainable in the long run so refactors of your components (changes to implementation but not functionality) don't break your tests and slow you and your team down.
The React Native Testing Library (RNTL) is a comprehensive solution for testing React Native components. It provides React Native runtime simulation on top of react-test-renderer
, in a way that encourages better testing practices. Its primary guiding principle is:
The more your tests resemble the way your software is used, the more confidence they can give you.
This project is inspired by React Testing Library. Tested to work with Jest, but it should work with other test runners as well.
Open a Terminal in your project's folder and run:
1# Yarn install: 2yarn add --dev @testing-library/react-native 3 4# NPM install 5npm install --save-dev @testing-library/react-native
This library has a peerDependencies
listing for react-test-renderer
. Make sure that your react-test-renderer
version matches exactly the react
version, avoid using ^
in version number.
You can use the built-in Jest matchers automatically by having any import from @testing-library/react-native
in your test.
1import { render, screen, userEvent } from '@testing-library/react-native'; 2import { QuestionsBoard } from '../QuestionsBoard'; 3 4// It is recommended to use userEvent with fake timers 5// Some events involve duration so your tests may take a long time to run. 6jest.useFakeTimers(); 7 8test('form submits two answers', async () => { 9 const questions = ['q1', 'q2']; 10 const onSubmit = jest.fn(); 11 12 const user = userEvent.setup(); 13 render(<QuestionsBoard questions={questions} onSubmit={onSubmit} />); 14 15 const answerInputs = screen.getAllByLabelText('answer input'); 16 17 // simulates the user focusing on TextInput and typing text one char at a time 18 await user.type(answerInputs[0], 'a1'); 19 await user.type(answerInputs[1], 'a2'); 20 21 // simulates the user pressing on any pressable element 22 await user.press(screen.getByRole('button', { name: 'Submit' })); 23 24 expect(onSubmit).toHaveBeenCalledWith({ 25 1: { q: 'q1', a: 'a1' }, 26 2: { q: 'q2', a: 'a2' }, 27 }); 28});
You can find the source of QuestionsBoard
component and this example here.
React Native Testing Library consists of following APIs:
render
function - render your UI components for testing purposesscreen
object - access rendered UI:
press
or type
in a realistic wayrenderHook
function - render hooks for testing purposesfindBy*
queries, waitFor
, waitForElementToBeRemoved
configure
, resetToDefaults
isHiddenFromAccessibility
within
, act
, cleanup
Check out our list of Community Resources about RNTL.
React Native Testing Library is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. Callstack is a group of React and React Native geeks, contact us at hello@callstack.com if you need any help with these or just want to say hi!
Like the project? ⚛️ Join the team who does amazing stuff for clients and drives React Native Open Source! 🔥
Supported and used by Rally Health.
No vulnerabilities found.
Reason
4 commit(s) and 9 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More