Quick Start

Installation

Open a Terminal in your project's folder and run:

npm
yarn
pnpm
bun
npm install -D @testing-library/react-native

This library has a peer dependency on Test Renderer. Make sure to install it:

npm
yarn
pnpm
bun
npm install -D test-renderer

Test Renderer has better compatibility with React 19 and improved type safety compared to the deprecated React Test Renderer.

Agent docs in the package

RNTL ships package-specific documentation for coding agents in node_modules/@testing-library/react-native/docs/. Add this snippet to your project's AGENTS.md or CLAUDE.md file so agents use the docs for the installed package version:

# React Native Testing Library in this project

This project uses `@testing-library/react-native`. Its APIs and testing conventions can differ from your training data.
Before writing or changing RNTL tests, read the relevant guide in
`node_modules/@testing-library/react-native/docs/`, starting with
`node_modules/@testing-library/react-native/docs/guides/llm-guidelines.md`.
Prefer those package docs over stale assumptions, and follow deprecation notices.

Jest matchers

RNTL automatically extends Jest with React Native-specific matchers. The only thing you need to do is to import anything from @testing-library/react-native which you already need to do to access the render function.

ESLint plugin

Set up eslint-plugin-testing-library to avoid common Testing Library mistakes and bad practices.

Install the plugin (assuming you already have eslint installed & configured):

npm
yarn
pnpm
bun
npm install -D eslint-plugin-testing-library

Then, add this to your ESLint config (e.g., .eslintrc.js). Extend the react plugin:

.eslintrc.js
module.exports = {
  overrides: [
    {
      // Test files only
      files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
      extends: ['plugin:testing-library/react'],
    },
  ],
};

Need React or React Native expertise you can count on?