You are viewing documentation for v14 alpha. This version is under active development and APIs may change.

Quick Start

Alpha Version

This version is currently in alpha. APIs and behavior may change before the stable release. Please report any issues you encounter.

Installation

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

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

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 provides better compatibility with React 19 and improved type safety compared to the deprecated React Test Renderer.

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

We recommend setting up eslint-plugin-testing-library package to help you 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 relevant entry to your ESLint config (e.g., .eslintrc.js). We recommend extending 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?