React Native · Mobile UI at native speed

How do you test a React Native app?

Mediumtestingjeste2eUpdated Oct 2026
Quiz this track

Short answer

Use Jest with React Native Testing Library for component behaviour, unit-test pure logic, mock native modules at the boundary, and cover critical journeys with Detox or Maestro on a real device or emulator.

The test pyramid still applies. Most tests should be fast component and logic tests. A smaller number of end-to-end tests cover flows that depend on native behaviour, navigation and real device APIs.

tsx
import { render, screen, fireEvent } from "@testing-library/react-native";
import { Counter } from "./Counter";

test("increments when pressed", () => {
  render(<Counter step={2} />);
  fireEvent.press(screen.getByText("Add 2"));
  expect(screen.getByText("2")).toBeOnTheScreen();
});
Query by what the user sees, not by component internals or test IDs when a label exists.

What to test at each level

  • Unit: reducers, formatters, validation and data transformations
  • Component: rendering states, accessibility labels, press and input behaviour
  • Integration: screen with navigation and a mocked data layer
  • E2E: login, checkout, onboarding and permission flows on a device
  • Snapshot tests sparingly; they fail on unrelated markup changes and are easy to rubber-stamp

Native modules need mocks in Jest because the native runtime is absent. Keep mocks small and close to the real contract; a mock that returns a different shape hides integration bugs. Use the library's provided mock where possible.

Do not test implementation details such as internal state names. Test observable behaviour, because refactors should not break tests that describe what the user experiences.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1What is the difference between Jest and Detox?
  2. 2How do you mock a native module?
  3. 3Why are snapshot tests overused?
  4. 4How do you test a permission flow?

Say it in the interview

I use Jest and React Native Testing Library for most behaviour tests, unit tests for pure logic, and a small E2E suite with Detox or Maestro for critical journeys that depend on native behaviour. I mock native modules at the boundary with realistic contracts and query by accessible text rather than internals. That keeps the suite fast while still covering the flows that only break on a device.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live React Native mock interview and get scored feedback on depth, clarity and confidence.