React Native E2E Tests with Maestro and Playwright on Expo

Prequel: How to Mock API Calls in React Native and Expo covered the mocks. This one is about the E2E runners on top of them.
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? My answer is that you want both, for different reasons. I ran one checkout journey two ways in a small Expo sample app: Playwright against the Expo web build, and Maestro on a native Android release build. The two specs share the journey and the testIDs, not a test file.
The full guide, with code, a recording of every step and the sources, is on devxtools.dev: React Native E2E Tests with Maestro and Playwright on Expo. The sample app is in sgedda/devxtools-tutorials.
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 and Node 22.23.5, on an Android 15 emulator (API 35, x86_64) and Expo Go 58.0.6. Everything ran on one local Linux machine with KVM (8 vCPU), so every time below is local, not CI. Not tested: GitHub-hosted runners, EAS Build, iOS, a dev-client build with Metro, physical devices.
Disclosure: I also build Mockifyer, a record/replay mocking library. The sample doesn't use it: its scenarios come from a small fake backend built into the app.
TL;DR
| Playwright on Expo web | Maestro on native Android | |
|---|---|---|
| Drives | The static web export (react-native-web) in Chromium | A release APK on an Android 15 emulator |
| Selectors | page.getByTestId('cart-total') | id: cart-total |
| Picks the mock scenario | /?mockScenario=payment-declined | launchApp arguments: { mockScenario: payment-declined } |
| Fresh state per test | New browser context | launchApp: { clearState: true } |
| Local run | 14 tests in 4.7–5.5 s | 4 flows in about 1 min 30 s |
| CI time | Not measured | Not measured |
| Misses | Native HTTP stack, Platform.OS branches, native-only modules | Web-only code paths; 2–3 s per tap |
Run Playwright on every PR. Run Maestro nightly or before a release, for the binary you actually ship.
One journey, shared testIDs
The sample (Northwind Supply) signs in, adds two products, checks the $218.00 cart total, places the order and expects Order NW-1001 confirmed. Other flows cover a declined card, a wrong password and an empty catalog.
All the testIDs live in one file, src/testIDs.ts. On Android a 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. So getByTestId() works with no config change. YAML can't import TypeScript, so the Maestro flows repeat the strings.
Keeping the network deterministic
Every call goes through one Api interface (login, listProducts, placeOrder), and EXPO_PUBLIC_API_MODE 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.tsholds the fake as plain functions: a demo user, three products and the order rules. Inmockmode (the default) the app calls them in-process after a 400 ms delay, long enough to see the loading state. Inhttpmode it calls a smallnode:httpserver on port 4010 that imports the same functions and reads the scenario from anX-Scenarioheader. - Scenarios. There are three:
default,empty-catalog(no products) andpayment-declined(checkout returns 402). Wrong password isn't a scenario:loginreturns 401 for any wrong credentials. - Choosing one.
src/scenario.tsreads?mockScenario=on web and themockScenariolaunch argument on native. Otherwise it usesEXPO_PUBLIC_SCENARIO, thendefault. 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. Mockifyer's React Native setup reads a scenario launch argument (via the optional react-native-launch-arguments), so a Maestro launchApp with arguments: { scenario: payment-declined } selects which recorded set to replay (verified on an Android debug build). It needs a native build, not Expo Go.
EXPO_PUBLIC_ values are inlined at build time, so switching modes means a new export or APK. Behind that seam you could use a local mock server (Mockoon, Prism), MSW in the browser (web build only), or record/replay such as Mockifyer. Launch arguments only reach Mockifyer 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.
Playwright on the Expo web build
npm ci npx playwright install chromium npm run build:web # dist-web (mock mode) and dist-web-http (HTTP mode) npm run test:web This should print 14 passed (2 projects × 7 tests). Three local runs took 4.7–5.5 s, and building both web exports took about 7 s. Every spec signs in by testID:
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() } Still from the web run. The clips are in the guide.
Maestro on a native Android build
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/ This should print 4/4 Flows Passed. Three local runs took about 1 min 30 s each (two of them on the final build): 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 downloads. A warm prebuild --clean plus rebuild took 106–110 s, and an emulator cold boot took 43 s. I built the APK locally with Gradle; EAS Build wasn't tested.
The flow picks its scenario with a launch argument:
- 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 launchApp arguments 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 (I only ran release builds). It worked on RN 0.88.1 with the New Architecture.
The traps
-
id:plustext:on a View.checkout-erroris a<View>wrapping a<Text>. Mergingid: checkout-errorandtext: '.*Your card was declined\. Nothing was charged\..*'into one Maestro selector fails withAssertion is false: ".*Your card was declined\. Nothing was charged\..*", id: checkout-error is visible. On Android the id and the text sit on separate nodes. Playwright'stoHaveTextpasses the same check, so assert the id and the text separately. - Removing
clearState. Run the checkout flow right after a normal run without it, and it fails at the first assertion: the app opens on the catalog ("Welcome back, Maya.") with the saved session. The cart doesn't leak, becauselaunchAppstops the app; only what's saved to disk survives. If your app persists nothing, removingclearStatechanges nothing. - Release builds block plain HTTP. In HTTP mode the emulator reaches the host at
10.0.2.2, but the first try showedCould not reach http://10.0.2.2:4010.The sample allows cleartext traffic only in HTTP-mode builds, so you rebuild withexpo prebuild --clean. After that,maestro test .maestro/http/passed 1/1 in 29 s. - Expo Go.
launchAppcan't target your app inside Expo Go, so useopenLinkwithexp://10.0.2.2:8081?__expo_disable_fab=1&__expo_disable_auto_launch=1&__expo_disable_onboarding=1. Without those flags,clearStatebrings back the dev-menu intro and the dev menu itself opens on launch. It passed 1/1 in 34 s, on the third try. Launch arguments don't reach your JavaScript in Expo Go.
CI: what's verified and what isn't
The sample's ci/e2e.yml runs Playwright on every PR and Maestro on manual dispatch only, using KVM and reactivecircus/android-emulator-runner@v2. It passes actionlint 1.7.12, and its npm, Expo, Gradle, adb and Maestro commands ran locally. It hasn't run on GitHub, so the KVM step and the emulator action are untested and no CI job times were measured.
GitHub's billing docs say standard runners are free for public repos; private repos use their included minutes, then pay per minute. The local numbers suggest the Android job will be the expensive one.
When to use which
- Playwright on Expo web for most journeys and every scenario. In the sample it takes about 2 s for the whole journey (0.6 s in HTTP mode).
- Maestro on native for the few journeys where the binary matters: launch, sign-in, payments, native modules, the native network stack.
- 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, which Maestro doesn't need.
The full walkthrough, with all nine step recordings, the CI workflow and the FAQ, is in the guide on devxtools.dev.
