---
name: test-react-native-components
description: Writes a React Native component check with React Native Testing Library, picking v13 or v14 from package.json and querying by role. Use when the user wants an RNTL component check, getByRole, or userEvent.
license: MIT
metadata:
  category: apps
  tags: "react-native"
  author: johnny-bravo
  version: "1.0"
  updated: "2026-11-09"
  status: published
  aliases: "react-native-testing, RNTL, @testing-library/react-native, userEvent"
  source_url: "https://github.com/callstack/react-native-testing-library/tree/0ecb9c9c0cef163e01abdeae1b4b7c82af40d0b1/skills/react-native-testing"
  source_license: MIT
  copyright: "Copyright (c) 2018 Callstack and Rally Health"
  original_author: "Callstack and Rally Health (callstack/react-native-testing-library, react-native-testing)"
  modified: "Adapted by TheSkillVault: rewritten as a short RNTL pass (v13 vs v14, role queries, userEvent, findBy); dropped the matcher tables and version reference files. Independent how-to, not official Testing Library documentation. No component check was run for this library."
  imported_on: "2026-11-09"
---

# Check React Native components with RNTL

React Native Testing Library renders a component and queries it the way a person would, by role and name. Match the major version in package.json. v13 and v14 do not behave the same.

## When to use
- A React Native component needs a render-and-query check.
- The file imports `@testing-library/react-native`.
- A press or a text change should go through userEvent.

## When not to use
- The need is a release-to-release diff. That is a separate skill.
- The need is a CI artifact. That is a separate skill.
- The need is a web page check in a browser. That is a separate skill.
- The project does not use this library.

## Steps
1. Read the `@testing-library/react-native` version. v14 is async render on React 19 and later. v13 is sync render on React 18. Do not mix their habits.
2. Query from `screen`. Do not destructure queries off `render`.
3. Prefer `getByRole` with a name. Use `queryBy` only to assert absence. Use `findBy` when the element appears later. Do not pair `waitFor` with `getBy` for that case.
4. Prefer `userEvent` for presses. It is async. Use `fireEvent` only when userEvent has no equivalent.
5. Keep side effects outside `waitFor`. Do not pass an empty callback. The library already wraps `render` and the event helpers, so do not add another wrapper.
6. This library did not run a component check, a simulator, or a device.

## Gotchas
- Do not include passwords, tokens, or private text in sample components.
- A `View` is not an accessibility element until it is marked accessible. `Text`, `TextInput`, and `Switch` already are. Prefer role and aria-label over older accessibility props.
- Training memory of this library is often stale. Trust the version in package.json, and do not guess a prop type from memory.
- This is an independent how-to adapted from a Callstack and Rally Health skill. It is not official Testing Library documentation, and no check was run for this library.

## Portability
If you use the web testing library, the same role-first query order still holds. If you use a bare assertion helper without this library, this skill does not cover that file. v13 and v14 stay different even inside React Native.

## Done when
- The skill followed v13 or v14 as package.json says.
- Queries go through `screen`, with `getByRole` first.
- Presses go through `userEvent` unless it cannot express the event.

## Example prompt
"Write an RNTL check for this React Native button. Use getByRole, userEvent, and the v14 async render if package.json says v14."

---
Adapted from "react-native-testing" by Callstack and Rally Health in callstack/react-native-testing-library (MIT, Copyright (c) 2018 Callstack and Rally Health). See LICENSE.txt.
