Mobile E2E Testing (Detox)

Mrs. Rini's test pyramid: many unit and component tests with Jest (jest-expo 57.0.5, Jest 29.7) and React Native Testing Library 14.1.0 (await render…

Before Mrs. Rini's new branch opens, there's a trial run. Checking each washing machine on its own is like a unit test. Having an employee pretend to be a customer, from walking in with laundry to receiving the receipt, is an E2E (end-to-end) test. In an app, that "employee" is a robot that uses the real app on a simulator or emulator exactly like a user: it opens the app, taps, then reads the screen.

The test pyramid for this app

Layer What's tested Tool How many
Unit plain functions: formatPrice(14) becomes '$14' Jest many
Component OrderRow shows #13 and passes on a tap Jest + React Native Testing Library quite a few
E2E open the app → see order #13 → open its detail Maestro or Detox few, key flows only

Unit and component tests run in seconds on a laptop. E2E tests need an app build and a simulator, so they're slow and more fragile: use them for flows whose breakage costs money (login, seeing an order, requesting a pickup). Versions as of 11 October 2026: jest-expo 57.0.5 (on Jest 29.7), @testing-library/react-native 14.1.0, Maestro CLI 2.11.0, Detox 20.51.4.

Component tests: Jest and React Native Testing Library

npx expo install jest-expo jest @types/jest --dev
npx expo install @testing-library/react-native --dev
npm install -D [email protected]   # RNTL 14 needs test-renderer, version 1.2 for React 19.2

In package.json: "jest": { "preset": "jest-expo" } and the script "test": "jest --watchAll". OrderRow moved to src/components/OrderRow.tsx and got a testID:

// src/components/__tests__/OrderRow.test.tsx
import { render, screen, userEvent } from '@testing-library/react-native';
import { OrderRow } from '@/components/OrderRow';
import type { Order } from '@/data/orders';

const order13: Order = { id: '13', name: 'Wulan', kg: 2, status: 'Ironing' };

test('OrderRow shows order #13 and sends its id when tapped', async () => {
  const onPress = jest.fn();
  const user = userEvent.setup();
  await render(<OrderRow order={order13} onPress={onPress} />);

  expect(screen.getByText('#13 Wulan')).toBeOnTheScreen();
  expect(screen.getByText('2 kg · $14')).toBeOnTheScreen();
  expect(screen.getByText('Ironing')).toBeOnTheScreen();

  await user.press(screen.getByTestId('order-13'));
  expect(onPress).toHaveBeenCalledWith('13');
});

Run in this project:

$ npx jest src/components/__tests__/OrderRow.test.tsx
PASS src/components/__tests__/OrderRow.test.tsx
  ✓ OrderRow shows order #13 and sends its id when tapped (460 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total

testID: a handle for the robot

<Pressable testID={`order-${order.id}`} onPress={() => onPress(order.id)}>

testID becomes the accessibility identifier on iOS and the view's identifier on Android. Jest, Maestro (id:) and Detox (by.id) all look it up there. Finding by text works too, but it breaks easily: translate or slightly change the text and the test fails.

Maestro: a flow in YAML

Maestro is a separate CLI (it needs Java 17+), installed with curl -fsSL "https://get.maestro.mobile.dev" | bash. The app doesn't change at all:

# .maestro/open-order-13.yaml
appId: com.rinislaundry.app
---
- launchApp:
    clearState: true
- assertVisible:
    id: "order-13"
- tapOn:
    id: "order-13"
- assertVisible: "Wulan: Ironing"

Detox: grey-box and synchronisation

Guess first: the order list comes from the server in 2 seconds. Your Detox test runs await expect(element(by.id('order-13'))).toBeVisible() right after the app opens, with no sleep. Pass or fail?

Detox (from Wix) writes tests in JavaScript with the Jest 29 runner, and its library is built into the app. Because it "sees inside" the app, Detox is called grey-box:

// e2e/order.test.js
describe('My orders', () => {
  beforeAll(async () => {
    await device.launchApp({ newInstance: true });
  });

  it('opens the detail of order #13', async () => {
    await expect(element(by.id('order-13'))).toBeVisible();
    await element(by.id('order-13')).tap();
    await expect(element(by.text('Wulan: Ironing'))).toBeVisible();
  });
});
Maestro Detox
Test language YAML JavaScript (Jest)
Waiting retries each check for up to 7 seconds waits for the app to be idle (grey-box)
Changes to the app none the Detox library is built in, plus a config plugin on Expo
Expo Go through openLink no, it needs its own build

Tests that sometimes pass, sometimes fail (flaky)

⚠️ Tests that are slow, brittle or read the screen too early

TL;DR: Mrs. Rini's test pyramid: many unit and component tests with Jest (jest-expo 57.0.5, Jest 29.7) and React Native Testing Library 14.1.0 (await render, userEvent.press, getByTestId), and a few E2E tests for the flow "open the app → order #13 → detail". testID (order-13 for order #13) is the handle for every tool. Maestro (CLI 2.11.0) writes flows in YAML (launchApp, assertVisible, tapOn with id), doesn't change the app, and retries each check for up to 7 seconds; Expo recommends it for EAS Workflows. Detox (20.51.4) is an end-to-end testing framework for React Native that runs tests on a real simulator or emulator, written in JavaScript, with grey-box automatic synchronisation: it waits for network, timers, animations and the JavaScript thread on its own, and for special cases uses waitFor().toBeVisible().withTimeout(). Tests turn flaky because of changing data, sleep, permission dialogs and leftover state: use fixed data, wait for the right thing, and start clean.

⚡ The test pyramid

Meaning: Many unit and component tests with Jest and React Native Testing Library, which run in seconds on a laptop. Few E2E tests, because they need a build and a simulator: enough for flows whose breakage costs money, such as "open the app → order #13 → detail".

⚡ testID, a handle for the robot

Write:

<Pressable testID={`order-${order.id}`} onPress={() => onPress(order.id)}>

Meaning: Jest, Maestro (id:) and Detox (by.id) all look up order-13 here. Finding by text works too, but it breaks easily when the text changes slightly.

⚡ Detox waits on its own

Guess first: the order list comes from the server in 2 seconds. Your Detox test runs toBeVisible() for order-13 right away, with no sleep. Pass or fail?

Pass. Before every action and check, Detox waits for the app to be idle: network requests, timers, animations and the JavaScript thread.

Meaning: That's grey-box automatic synchronisation. For things outside synchronisation, such as data over a WebSocket, use waitFor(...).toBeVisible().withTimeout(5000), not sleep.

What you will learn