# React Native Testing Library

> Helps you to write better tests with less effort.

## Docs

- [Introduction](/react-native-testing-library/docs/start/intro.md)
- [Quick Start](/react-native-testing-library/docs/start/quick-start.md)
- [Migration to 14.x](/react-native-testing-library/docs/start/migration-v14.md): This guide describes the migration to React Native Testing Library version 14 from version 13.x.
- [`render` API](/react-native-testing-library/docs/api/render.md)
- [`screen` object](/react-native-testing-library/docs/api/screen.md): The screen object provides access to queries and utilities for the currently rendered UI. This object is assigned after the render call and cleared after each test by calling cleanup. If no render call has been made in a given test, then it holds a special object and throws a helpful error on each property and method access. ...queries The main feature of screen is its queries for finding elements in the view hierarchy. See Queries for a complete list. Example rerender Re-render the in-memory tree with a new root element. This simulates a React update render at the root. If the new element has the same type (and key) as the previous element, the tree will be updated; otherwise, it will re-mount a new tree, in both cases triggering the appropriate lifecycle events. This method is async and uses async act internally to execute all pending React updates during updating. This works with async React features like Suspense boundaries and the use() hook. unmount Unmount the in-memory tree, triggering the appropriate lifecycle events. This method is async and uses async act internally to execute all pending React updates during unmounting. This works with async React features like Suspense boundaries and the use() hook. debug Pretty prints deeply rendered component passed to render. message option {#debug-message-option} You can provide a message that will be printed on top. logs optional message and colored JSX: mapProps option {#debug-map-props-option} You can use the mapProps option to transform the props that will be printed : This will log the rendered JSX without the style props. The children prop cannot be filtered out so the following will print all rendered components with all props but children filtered out. This option can be used to target specific props when debugging a query (for instance, keeping only the children prop when debugging a getByText query). You can also transform prop values so that they are more readable (e.g., flatten styles). Or remove props that have little value when debugging tests, e.g. path prop for svgs toJSON Get the rendered component JSON representation, e.g. for snapshot testing. container Returns a pseudo-element container whose children are the elements you asked to render. This is the root container element from Test Renderer. The container provides access to the entire rendered tree. Use it to query or manipulate the rendered output, similar to how container works in React Testing Library. root Returns the rendered root host element, or null if nothing was rendered. This is the first child of the container, which represents the actual root element you rendered. This API is useful for component tests where you need to access the root host view without using *ByTestId queries or similar methods.
- [Queries](/react-native-testing-library/docs/api/queries.md): Queries are one of the main building blocks for the React Native Testing Library. They enable you to find relevant elements in the element tree, which represents your application's user interface when running under tests.
- [Jest matchers](/react-native-testing-library/docs/api/jest-matchers.md): This guide covers the built-in Jest matchers. These matchers make your tests easier to read and work better with accessibility features.
- [Fire Event API](/react-native-testing-library/docs/api/events/fire-event.md)
- [User Event interactions](/react-native-testing-library/docs/api/events/user-event.md)
- [Accessibility](/react-native-testing-library/docs/api/misc/accessibility.md)
- [Async utilities](/react-native-testing-library/docs/api/misc/async.md)
- [Configuration](/react-native-testing-library/docs/api/misc/config.md)
- [Other helpers](/react-native-testing-library/docs/api/misc/other.md)
- [`renderHook` function](/react-native-testing-library/docs/api/misc/render-hook.md)
- [How should I query?](/react-native-testing-library/docs/guides/how-to-query.md): React Native Testing Library provides various query types for finding views in tests. The number of queries can be confusing. This guide helps you pick the right queries for your test scenarios.
- [Common Mistakes with React Native Testing Library](/react-native-testing-library/docs/guides/common-mistakes.md): Note: This guide is adapted from Kent C. Dodds' article "Common mistakes with React Testing Library" for React Native Testing Library v14. The original article focuses on web React, but the principles apply to React Native as well. This adaptation includes React Native-specific examples, async API usage (v14), and ARIA-compatible accessibility attributes. React Native Testing Library guiding principle is: "The more your tests resemble the way your software is used, the more confidence they can give you." This guide outlines some common mistakes people make when using React Native Testing Library and how to avoid them.
- [LLM Guidelines for React Native Testing Library](/react-native-testing-library/docs/guides/llm-guidelines.md): Actionable guidelines for writing tests with React Native Testing Library (RNTL) v14.
- [Troubleshooting](/react-native-testing-library/docs/guides/troubleshooting.md): This guide describes common issues found by users when integrating React Native Test Library to their projects:
- [FAQ](/react-native-testing-library/docs/guides/faq.md)
- [Community resources](/react-native-testing-library/docs/guides/community-resources.md)
- [Testing environment](/react-native-testing-library/docs/advanced/testing-env.md): React Native Testing Library lets you write integration and component tests for your React Native app or library. While the JSX code in tests closely resembles your React Native app, the underlying environment differs. This document describes the key elements of our testing environment and highlights things to be aware of when writing advanced tests or diagnosing issues.
- [Third-Party Library Integration](/react-native-testing-library/docs/advanced/third-party-integration.md): The React Native Testing Library is designed to simulate the core behaviors of React Native. However, it does not replicate the internal logic of third-party libraries. This guide explains how to integrate your library with RNTL.
- [Understanding `act` function](/react-native-testing-library/docs/advanced/understanding-act.md): When writing RNTL tests, cryptic act() function errors logged to console often confuse developers. This article explains the purpose and behavior of act() so you can write tests with more confidence.
- [API Overview](/react-native-testing-library/docs/api.md): React Native Testing Library consists of following APIs: render function - render your UI components for testing purposesscreen object - access rendered UI:Queries - find relevant components by various predicates: role, text, test ids, etcLifecycle methods: rerender, unmountHelpers: debug, toJSON, rootJest matchers - validate assumptions about your UIUser Event - simulate common user interactions like press or type in a realistic wayFire Event - simulate any component event in a simplified way purposesMisc APIs:renderHook function - render hooks for testingAsync utils: findBy* queries, waitFor, waitForElementToBeRemovedConfiguration: configure, resetToDefaultsAccessibility: accessible name, isHiddenFromAccessibilityOther: within, act, cleanup

## Cookbook

- [Introduction](/react-native-testing-library/cookbook/index.md): Welcome to the React Native Testing Library (RNTL) Cookbook! This app is your go-to resource for learning how to effectively test React Native applications. It provides a collection of best practices, ready-made recipes, and tips & tricks to simplify and improve your testing workflow. Whether you’re a beginner just getting started or a seasoned developer looking to sharpen your skills, the Cookbook has something for everyone.
- [Async Events](/react-native-testing-library/cookbook/basics/async-events.md)
- [Custom `render` function](/react-native-testing-library/cookbook/basics/custom-render.md): Summary RNTL exposes the render function as the primary entry point for tests. If you make complex, repeating setups for your tests, consider creating a custom render function. The idea is to encapsulate common setup steps and test wiring inside a render function suitable for your tests. Example Example full source code. More info Additional params A custom render function might accept additional parameters to allow for setting up different start conditions for a test, e.g., the initial state for global state management. Multiple functions Depending on the situation, you may declare more than one custom render function. For example, you have one function for testing application flows and a second for testing individual screens. Async setup Since render is async, your custom render function should be marked as async and use await render(). This pattern also makes it easy to add additional async setup if needed:
- [Network Requests](/react-native-testing-library/cookbook/advanced/network-requests.md)
- [Jotai](/react-native-testing-library/cookbook/state-management/jotai.md)

## Others

- [](/react-native-testing-library/404.md)