DevXTools

React Native E2E Tests with Maestro and Playwright on Expo

Tested with Expo SDK 58.1.0, react-native 0.88.1 (New Architecture), react 19.3.0, react-native-web 0.21.4, react-native-launch-arguments 4.1.1, @playwright/test 1.65.1 (Chromium), Maestro CLI 2.13.0, Node 22.23.5; Android 15 emulator (API 35, x86_64) and Expo Go 58.0.6. Playwright 14/14 passing in three runs, Maestro 4/4 passing in three runs (two on the final build), on one local Linux machine on 2026-11-29. Not run on GitHub-hosted runners. Repro: sgedda/devxtools-tutorials (rn-e2e-maestro-playwright)

Most Expo teams end up asking the same thing: do I need an Android emulator in CI, or is Playwright on the web build enough? The short answer is that you want both, for different reasons. This guide runs one checkout journey two ways in a small Expo sample app: Maestro on a native Android release build, and Playwright against the Expo web build. The two specs share the journey and the testIDs, not a test file. Each section shows the commands to run, a short recording of the real run, and where the other tool (or Detox) wins.

The versions and results are in the box above. Everything ran on one local Linux machine with KVM (8 vCPU), so all the times below are local, not CI. The example GitHub Actions workflow is syntax-checked but hasn’t run on GitHub. We also didn’t test iOS, EAS Build, a dev-client build with Metro, or physical devices.

Disclosure: devxtools.dev is run by Sebastian, who also builds Mockifyer, a record/replay mocking library. It’s used by WanderWeird, a separate example app cited below; this tutorial’s sample doesn’t use Mockifyer. devxtools.dev has no relationship with Maestro, Playwright, Detox or Expo.

TL;DR: Maestro native vs Playwright on Expo web

Same journey, separate specs, shared testIDs. Playwright on the web build is the cheap, fast check you run on every pull request. Maestro on a native build is the one that catches native bugs, and it costs an emulator.

Playwright on Expo webMaestro on native Android
What it drivesThe static web export (react-native-web) in ChromiumA release APK on an Android 15 emulator
Selectorspage.getByTestId('cart-total')id: cart-total
Picks the mock scenario/?mockScenario=payment-declinedlaunchApp arguments: { mockScenario: payment-declined }
Fresh state per testNew browser contextlaunchApp: { clearState: true }
Local run (sample)14 tests in 4.7–5.5 s4 flows in about 1 min 30 s
CI timeNot measured for the sampleNot measured
What it missesNative HTTP stack, Platform.OS branches, native-only modules, Android UIWeb-only code paths; slower feedback (2–3 s per tap)
Best forEvery PR: flows, states, scenarios, tracesNightly or pre-release: the binary you ship

What you’ll build: one flow, two runners

The sample is Northwind Supply, a small Expo app in sgedda/devxtools-tutorials. The journey: sign in, add two products, check the cart total ($218.00), place the order, and see Order NW-1001 confirmed. Two failure flows reuse it: a declined card that keeps the cart, and a wrong password. A fourth flow checks the empty catalog.

  • Playwright specs in e2e/ drive the web export (expo export --platform web), served as static files.
  • Maestro flows in .maestro/ drive a release APK on an emulator. A release APK embeds the JS bundle, so no Metro server is needed.

The rule for both runners: share the journey and the IDs, keep the specs separate. Maestro reads YAML and talks to the device’s accessibility layer. Playwright is TypeScript driving a browser. .maestro/checkout.yaml and e2e/checkout.spec.ts follow the same steps and assert the same texts.

git clone -b rn-e2e-maestro-playwright https://github.com/sgedda/devxtools-tutorials.git
cd devxtools-tutorials/rn-e2e-maestro-playwright
npm ci

You need Node.js 22. For the native half you also need JDK 17 or later (21 worked), the Android SDK, an x86_64 emulator with KVM (or a device), and the Maestro CLI.

Setup: shared testIDs (and the react-native-web data-testid mapping)

Text selectors break the day someone renames a button or translates the app. testIDs don’t, and both runners can use them. The sample keeps them in one file, src/testIDs.ts:

export const T = {
  loginScreen: 'login-screen',
  emailInput: 'email-input',
  passwordInput: 'password-input',
  signInButton: 'sign-in-button',
  // ...
  cartButton: 'cart-button',
  cartScreen: 'cart-screen',
  cartTotal: 'cart-total',
  placeOrderButton: 'place-order-button',
  checkoutError: 'checkout-error',
  // ...
  scenarioLabel: 'scenario-label',
  signOutButton: 'sign-out-button',
} as const

On Android, testID becomes the view’s resource id, which Maestro matches with id:. On the web, react-native-web renders it as data-testid, which is Playwright’s default test id attribute. In the sample’s DOM the scenario label renders as <div dir="auto" class="css-146c3p1 …" data-testid="scenario-label">API: mock · scenario: payment-declined</div>, and no testID attribute is left over. So getByTestId() works with no config change. The sample’s playwright.config.ts sets testIdAttribute: 'data-testid' anyway, just to make it explicit.

YAML can’t import TypeScript, so the Maestro flows repeat the strings. Keep that one file as the contract, and change it before you change either suite.

Keeping the network deterministic

Both runners are only as stable as the backend. The sample puts one API interface in front of the network, backed by a fake that both runners share (how it’s built). Behind that seam you can use:

  • A local mock server such as Mockoon or Prism, for both runners. The emulator reaches your machine as 10.0.2.2.
  • MSW in the browser, for the web build only.
  • Record/replay such as Mockifyer (disclosure above; the sample doesn’t use it). Launch arguments only reach it if the app installs react-native-launch-arguments.

When hand-written fakes stop scaling, record/replay is the usual next step; see Record and replay real responses.

How the sample’s fake backend works

Every call goes through one Api interface (login, listProducts, placeOrder) in src/api/client.ts, which picks the implementation:

export function createApi(scenario: Scenario): Api {
  return process.env.EXPO_PUBLIC_API_MODE === 'http' ? httpApi(scenario) : mockApi(scenario)
}
  • One fake, two transports. src/api/backend.ts holds the fake as plain functions: a demo user, three products and the order rules. In mock mode (the default) the app calls those functions in-process after a 400 ms delay, long enough to see the loading state. In http mode it calls mock-server/server.ts, a node:http server on port 4010 that imports the same functions and reads the scenario from an X-Scenario header.
  • Scenarios. There are three: default, empty-catalog (no products) and payment-declined (checkout returns 402, “Your card was declined. Nothing was charged.”). Wrong password isn’t a scenario: login returns 401 for any wrong credentials.
  • Choosing one. src/scenario.ts reads ?mockScenario= on web and the mockScenario launch argument on native. Otherwise it uses EXPO_PUBLIC_SCENARIO, then default. Expo Go doesn’t link the launch-arguments module, so it gets the fallback.

The sample hand-codes each scenario’s responses in backend.ts. With record/replay such as Mockifyer, you record each scenario once from real responses instead, and a Maestro launch argument (launchApp with arguments: { scenario: payment-declined }) selects which recording to replay. That needs the optional react-native-launch-arguments package and a native build, not Expo Go.

Expo inlines EXPO_PUBLIC_ values at build time, so switching modes means a new web export or APK.

Playwright against the Expo web build

The web run is where you catch broken flows and states on every pull request. Build the two web exports (mock and HTTP mode), then run the suite. Playwright’s webServer serves both exports on :8081 and :8082 and starts the mock server on :4010:

npx playwright install chromium
npm run build:web     # dist-web (mock mode) and dist-web-http (HTTP mode)
npm run test:web

Checkpoint: 14 passed (2 projects × 7 tests; the clip-recording specs are skipped). Three local runs took 4.7–5.5 s, and building both web exports took about 7 s.

Signing in is shared by every spec, through the testIDs:

export async function signIn(page: Page, scenario?: string) {
  await page.goto(scenario ? `/?mockScenario=${scenario}` : '/')
  await expect(page.getByTestId(T.loginScreen)).toBeVisible()
  await page.getByTestId(T.emailInput).pressSequentially(USER.email, { delay: RECORDING ? 30 : 0 })
  await page.getByTestId(T.passwordInput).fill(USER.password)
  await page.getByTestId(T.signInButton).click()
  await expect(page.getByTestId(T.catalogScreen)).toBeVisible()
}

On the web, the mock scenario comes from the ?mockScenario= URL parameter.

Step 1 (web).Watch the label read API: mock · scenario: default, then the email and password fill in and the catalog greets Maya.(Video, 6 s, no audio.)

Then the journey itself, step for step the same as .maestro/checkout.yaml:

test('signs in, orders two products and sees the confirmation', async ({ page, pace }) => {
  await signIn(page)
  await expect(page.getByText('Welcome back, Maya.')).toBeVisible()
  await expect(page.getByTestId(T.product('NW-KBD-01'))).toContainText('Mechanical keyboard')
  await pace()

  await page.getByTestId(T.addToCart('NW-KBD-01')).click()
  await page.getByTestId(T.addToCart('NW-DOCK-03')).click()
  await expect(page.getByTestId(T.cartButton)).toHaveText('View cart (2)')
  await pace()

  await page.getByTestId(T.cartButton).click()
  await expect(page.getByTestId(T.cartScreen)).toBeVisible()
  await expect(page.getByTestId(T.cartTotal)).toHaveText('$218.00')
  await pace()

  await page.getByTestId(T.placeOrderButton).click()
  await expect(page.getByTestId(T.orderId)).toHaveText('Order NW-1001 confirmed')
  await expect(page.getByText('2 items · $218.00 charged')).toBeVisible()
  await pace(1200)
})

(pace() only pauses while recording clips.)

Step 2 (web).Watch both Add buttons switch to Added (1) and the cart button change to View cart (2).(Video, 7 s, no audio.)
Step 3 (web).Watch the cart total read $218.00, then Place order land on Order NW-1001 confirmed.(Video, 6 s, no audio.)

The declined-card spec signs in with payment-declined and checks that the error shows while the cart survives:

Step 4 (web).Watch the order fail with Your card was declined. Nothing was charged., while the $249.00 cart stays in place.(Video, 6 s, no audio.)

The web-http project runs the same specs against the HTTP-mode export, so the fetch calls really go to the mock server on :4010:

Step 5 (web).Watch the label read API: http this time, then the same sign-in and order complete against the HTTP mock server.(Video, 7 s, no audio.)

A bigger real-world example of this runner: the WanderWeird Expo app’s Playwright suite in sgedda/mockifyer runs against the Expo web build in CI. Its e2e job took 5–8 minutes on recent pull-request runs and 23–24 minutes on nightly runs that record video (runs linked in Sources). Its README is explicit about scope: it covers the web build, “not native React Native code paths”.

For Playwright mocking basics outside React Native (page.route, HAR replay), see how to mock API calls in Playwright.

Maestro on a native Android build

The native run is where you catch what the web run can’t see: the release APK, the native network stack, Android-only Platform.OS branches and native modules. Maestro needs no test code inside your app: it tests the built binary at the accessibility layer (Maestro docs).

npx expo prebuild --platform android
(cd android && ./gradlew assembleRelease -PreactNativeArchitectures=x86_64)
adb install -r android/app/build/outputs/apk/release/app-release.apk
maestro test .maestro/

Checkpoint: 4/4 Flows Passed. Three local runs (two on the final build) took about 1 min 30 s each: checkout 28 s, declined card 25 s, wrong password 18 s, empty catalog 18 s. The first native build took 4 min 40 s, including Gradle, NDK and SDK downloads. expo prebuild --clean plus a warm rebuild took 106–110 s, and an emulator cold boot took 43 s. Building only x86_64 (the emulator’s ABI) cuts the native build time. We built the APK locally with Gradle; EAS Build wasn’t tested.

The checkout flow, step for step the same as the Playwright spec:

appId: com.northwind.e2esample
name: Checkout journey
tags:
  - journey
---
- launchApp:
    clearState: true # wipe app data (the saved session) so every run starts signed out
    arguments:
      mockScenario: default # read in src/scenario.ts via react-native-launch-arguments
- assertVisible:
    id: scenario-label
    text: '.*scenario: default'
- runFlow: sign-in.yaml
- assertVisible: 'Welcome back, Maya.'
- assertVisible:
    id: product-NW-KBD-01
- tapOn:
    id: add-NW-KBD-01
- tapOn:
    id: add-NW-DOCK-03
- assertVisible:
    id: cart-button
    text: 'View cart \(2\)'
- tapOn:
    id: cart-button
- assertVisible:
    id: cart-screen
- assertVisible:
    id: cart-total
    text: '\$218\.00'
- tapOn:
    id: place-order-button
- assertVisible:
    id: order-id
    text: 'Order NW-1001 confirmed'
- assertVisible: '2 items · \$218\.00 charged'

launchApp arguments (reference) only reach your JavaScript if the app installs react-native-launch-arguments. It’s a native module, so it needs a release or dev build (we only ran release builds). It worked on RN 0.88.1 with the New Architecture. The sample reads it in src/scenario.ts:

const { LaunchArguments } = require('react-native-launch-arguments') as typeof import('react-native-launch-arguments')
fromRun = LaunchArguments.value<{ mockScenario?: string }>().mockScenario

The login screen prints API: <mode> · scenario: <name> (testID scenario-label), so each flow can assert that the scenario actually arrived. sign-in.yaml is a shared sub-flow. It calls hideKeyboard before tapping Sign in; we didn’t test whether that step is needed.

Step 1 (Android).Played at 2x speed (about 19 s in real time): Maestro types the email and password into the release APK and lands on the catalog.(Video, 9 s, no audio.)
Step 2 (Android).Watch Maestro tap the same two Add buttons by id and the cart button change to View cart (2).(Video, 7 s, no audio.)
Step 3 (Android).Watch the $218.00 cart turn into Order NW-1001 confirmed, the same text the web spec asserts.(Video, 7 s, no audio.)

Try breaking it: in .maestro/payment-declined.yaml, merge the two checks into one selector, id: checkout-error plus text: '.*Your card was declined\. Nothing was charged\..*'. Maestro fails with Assertion is false: ".*Your card was declined\. Nothing was charged\..*", id: checkout-error is visible. checkout-error is a <View> wrapping a <Text>, and on Android the id and the text sit on separate nodes. Playwright’s toHaveText reads the DOM text content, so the web spec passes the same check. Assert the id and the text separately, or put the testID on the <Text>.

Step 4 (Android).Watch the declined-card error appear above the cart on Android, with the $249.00 total still there.(Video, 7 s, no audio.)

Try breaking it: delete clearState: true from .maestro/checkout.yaml and run it right after a normal run. In our two runs it failed at the first assertion, because the app opened straight on the catalog (“Welcome back, Maya.”) with the session saved from the previous run. The cart didn’t leak: launchApp stops the app by default, so in-memory state is gone and only what the app saves to disk survives. If your app persists nothing, removing clearState changes nothing. Playwright’s equivalent is the fresh browser context each test gets.

HTTP mode and the 10.0.2.2 trap

The sample can also build the APK in HTTP mode, so the native network stack really talks to the mock server on your machine. The emulator reaches the host at 10.0.2.2 (Android docs). The first try showed Could not reach http://10.0.2.2:4010., because release builds block plain HTTP. The sample’s app.config.ts allows cleartext traffic only in HTTP-mode builds, so you rebuild with --clean:

npm run mock-server &
EXPO_PUBLIC_API_MODE=http npx expo prebuild --platform android --clean
(cd android && EXPO_PUBLIC_API_MODE=http ./gradlew assembleRelease -PreactNativeArchitectures=x86_64)
adb install -r android/app/build/outputs/apk/release/app-release.apk
maestro test .maestro/http/

That passed 1/1 in 29 s. Rebuild without EXPO_PUBLIC_API_MODE (and with --clean) to go back to mock mode.

Expo Go

With Expo Go there’s no APK of your own, so launchApp can’t target your app. Use openLink with your exp:// URL instead. It passed 1/1 in 34 s on the third try, after two traps. clearState brings back Expo Go’s developer-menu intro sheet, and then the dev menu itself opens on launch. The fix is the query flags expo start --android uses:

- openLink: exp://10.0.2.2:8081?__expo_disable_fab=1&__expo_disable_auto_launch=1&__expo_disable_onboarding=1

Launch arguments don’t reach your JavaScript in Expo Go, so this path always runs the default scenario.

Running both in CI (GitHub Actions, KVM and emulator cost)

The sample’s ci/e2e.yml is an example workflow. It runs the Playwright job on every pull request and the Maestro job on manual dispatch only. It passes actionlint 1.7.12, and its npm, Expo, Gradle, adb and Maestro commands ran locally. It hasn’t run on GitHub: the KVM udev step and android-emulator-runner@v2 weren’t run anywhere, and no CI job times were measured. The emulator part:

- name: Enable KVM
  run: |
    echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
    sudo udevadm control --reload-rules
    sudo udevadm trigger --name-match=kvm

- name: Run Maestro on an emulator
  uses: reactivecircus/android-emulator-runner@v2
  with:
    api-level: 35
    target: google_apis
    arch: x86_64
    profile: pixel_6
    disable-animations: true
    emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -no-audio -no-boot-anim -camera-back none
    # Each line runs as its own shell command.
    script: |
      adb install -r android/app/build/outputs/apk/release/app-release.apk
      maestro test .maestro/ --format junit --output maestro-report.xml

The KVM step is the one the android-emulator-runner README documents. On cost, GitHub’s billing docs say standard runners are free for public repositories. Private repositories use the account’s included minutes, then pay per minute. The local numbers suggest the Android job will be the expensive one: a cold native build, an emulator boot and about 1.5 min of Maestro, on a machine with twice the vCPUs of a public ubuntu-latest runner. The web job is npm ci, 7 s for the two web exports and a 5 s suite. That’s why the example runs Playwright on every PR and keeps Maestro manual until you’ve measured what it costs you. Caching Gradle (gradle/actions/setup-gradle) and building only x86_64 are the cheap wins.

When to use which

  • Playwright on Expo web for most journeys: every PR, every scenario (empty, declined, wrong password), traces on failure, no emulator. In the sample it takes about 2 s for the whole journey (0.6 s in HTTP mode).
  • Maestro on native for the handful of journeys where the binary matters: launch, sign-in, payments, anything with native modules, the native network stack or Platform.OS branches. It needs no instrumentation and its YAML flows are easy to read. Budget 2–3 s per tap on an emulator.
  • Detox if you want gray-box tests that sync with the app’s idle state. The cost is native test code in your app project (Detox’s Android setup adds a DetoxTest instrumentation test), which Maestro doesn’t need.
  • Web-only apps don’t need any of this. Tutorials #1 (React) and #2 (Next.js) cover Playwright with MSW in depth.

FAQ

Can one test file drive both Maestro and Playwright?

No. Maestro runs YAML flows against a device, Playwright runs TypeScript against a browser. Share the journey and the testIDs, and keep two short specs. In the sample, .maestro/checkout.yaml and e2e/checkout.spec.ts use the same ids and expected texts.

Does Playwright on the Expo web build catch native bugs?

No. It runs react-native-web in Chromium, so the native HTTP stack, Platform.OS branches and native-only modules are never exercised. The release-build cleartext block on Android (Could not reach http://10.0.2.2:4010.) is one example a web run can’t see.

Do I need an Android emulator in CI?

Only for the Maestro job. Playwright on the web build needs no emulator. Locally, the native side took 4 min 40 s for a first build, about 2 min for a warm rebuild, 43 s for an emulator cold boot and about 1 min 30 s for four Maestro flows. We haven’t measured either job on GitHub-hosted runners.

Can I use Maestro with Expo Go?

Yes. Use openLink with your exp:// URL instead of launchApp, because your app runs inside Expo Go. Add __expo_disable_fab=1&__expo_disable_auto_launch=1&__expo_disable_onboarding=1 to the URL so the dev menu doesn’t cover the app. Launch arguments don’t reach your JavaScript in Expo Go; development and release builds use launchApp.

Where does Detox fit?

Detox needs native test code added to your app project (gray-box), Maestro doesn’t (black-box). See Detox.

How do I keep API responses stable across both runners?

Put the API behind a seam picked by an EXPO_PUBLIC_ variable, and point test builds at an in-app fake, a mock server, MSW (web only) or record/replay, as in keeping the network deterministic. EXPO_PUBLIC_ values are fixed at build time, so switching needs a rebuild. How to mock APIs in React Native compares the approaches.

Maestro · Playwright · Detox · How to mock APIs in React Native · How to mock API calls in Playwright · MSW in React with Playwright · MSW in Next.js with Playwright · Testing tools


Sources (checked 2026-11-29)

Find tools for your stack

Answer a few questions to find tools that match your needs.