Skip to content
Blogs

Reducing Flaky E2E Tests in Expo Apps

· 20 min read

A green CI badge that needs three reruns is not confidence—it is normalized luck. Staff engineers treat mobile E2E flake rate like an error budget: measured, owned, quarantined with deadlines, and split into fast PR smoke versus nightly real-device truth.

Flaky E2E is a trust problem

Animation races, Metro reload timing, push permission dialogs, and live network dependencies turn mobile end-to-end tests into a lottery. Teams that "just retry" teach themselves to ignore red builds until a release train stops cold on submission day.

Staff engineers publish flake rate beside build duration and make it a release criterion. When the suite is unreliable, product cannot trust weekly Expo shipping—even if feature velocity looks fine on paper.

Treat the test system as product infrastructure. When flakes exceed a threshold, freeze new specs until each failure has an owner, a reproduction artifact, and a root-cause hypothesis. Adding more tests on a flaky foundation multiplies noise, not safety.

Mobile is not small web: OS kills background tasks, keyboards cover inputs, and native modules initialize asynchronously. Flakes often reveal missing contracts in the app, not "bad tests." Fixing synchronization is engineering work with the same priority as a production crash.

Instrument flake rate in the same analytics warehouse as crashes. When E2E reliability drops below a threshold, auto-page the mobile platform owner—not the last engineer who touched a unrelated feature.

Wait on contracts, not clocks

Use fixed test accounts, seeded Supabase rows or staging fixtures, and known API responses. Stub HTTP at the client boundary when the goal is UI flow—not backend correctness. Reserve a smaller integration suite that hits real services on a schedule, not on every pull request.

Replace arbitrary `sleep(5000)` with visibility predicates, network idle hooks, or runner-specific sync APIs. If a test documents time instead of state, it is begging to flake when CI runners get slower or animations change duration.

Record video and network traces on failure once per quarantined spec—not on every retry in the main pipeline. Artifacts should explain the flake; infinite retries recreate it probabilistically and burn minutes.

Reset application state deterministically between specs: clear AsyncStorage keys, revoke session tokens, and restart the dev client when tests mutate global navigation. Shared state leaks are the silent cause of "works locally, fails in CI."

Log which spec left dirty state when isolation fails. A single order-dependent test poisons the entire shard—fix order dependence instead of shuffling files until green.

| Anti-pattern | Replacement | | --- | --- | | Fixed sleep after tap | Wait for testID visible + enabled | | Live payment sandbox | Stub checkout success JSON | | Random test user email | Seeded account per worker | | Full suite on every push | Smoke subset + nightly matrix |

Deep links and cold starts deserve dedicated specs: killing the app mid-flow exposes navigation stacks that unit tests never exercise. Run those specs on release candidates only if they are too heavy for every PR—but never skip them entirely before store submission.

Quarantine with discipline

Move flaky specs to a quarantine job with a named owner, fix-by date, and link to the tracking issue. Unlimited retries in the required check hide debt and teach engineers that red means "run again," not "stop shipping."

When a quarantined test fails consistently, that is progress—it became deterministic enough to debug. Celebrate narrowing reproduction steps; that is how staff work differs from muting alerts.

Review quarantine weekly with release managers. Items past SLA should block the train, force deletion of the spec, or downgrade coverage explicitly in the release notes. "Quarantined forever" is the mobile equivalent of a critical bug backlog nobody owns.

Track quarantine age and count in the same dashboard as open Sev-1 bugs. Leadership should see when mobile confidence debt exceeds a sprint of fix capacity—that is when you pause feature E2E and fund stabilization.

Tag quarantine issues with the last known green commit. Bisecting app changes beats guessing whether Metro, the runner, or the backend drifted. Mobile flakes without bisect metadata rarely get fixed—they get muted.

Layer CI realistically

Run a fast smoke suite on every pull request: login, one critical path, one payment or save action. Run the full device matrix nightly or pre-release on real hardware. Emulators catch logic; physical devices catch keyboard overlap, biometric prompts, and vendor-specific WebView quirks.

Expo development builds belong in CI—not Expo Go alone—when native modules, push, or deep links matter. Document which flows are Go-safe versus dev-client-only so contributors do not waste hours on unsupported paths.

Parallelize by shard, not by duplicating flaky specs across shards. Sharding multiplies the same race if the underlying test is unsynchronized. Fix the spec, then scale parallelism.

Publish flake rate and median duration per job beside mobile release metrics. Product should feel the cost of ignoring CI health the same way they feel crash-free sessions.

EAS Build and submit pipelines should gate on the smoke suite, not on a full hour-long matrix that teams skip informally. Make the required check honest about what it proves.

Rotate CI devices when OS minor versions ship—Apple and Google patch WebView and keyboard behavior without your semver bump. A green matrix on last month's OS is not proof for this week's store build.

Pick Maestro or Detox deliberately

Maestro favors readable YAML flows and fast author onboarding; Detox offers deeper JavaScript synchronization with React Native internals. Neither removes the need for deterministic fixtures—both fail loudly when the app hides elements behind animations or loading gates without test hooks.

Standardize on `testID` (or accessibility labels used only in test builds) for every interactive control in money paths. Design reviews should reject flows that cannot be targeted without coordinate taps.

Keep runner version pins in lockstep with Expo SDK upgrades. SDK bumps change layout timing, Hermes behavior, and native module init order—budget a stabilization sprint after major upgrades, not zero test churn.

Avoid mixing two runners on the same critical path without reason. Dual stacks double maintenance and disagree on sync semantics. Pick one primary runner for product flows; use the second only for experiments with an exit plan.

Coach designers to expose loading and error states with stable test hooks—not only polished success screens. E2E cannot wait on spinners that lack accessibility identifiers without resorting to brittle timeouts.

Expo fixtures and network stubs

```typescript // app.config.ts — expose test-only deep link handler in dev builds export default { scheme: "myapp", extra: { e2eSeed: process.env.E2E_SEED ?? "default", }, };

// tests/helpers/stubFetch.ts — intercept before UI spec runs export async function stubCheckoutSuccess(page: MaestroPage) { await page.mockNetwork({ url: "**/api/checkout", response: { status: 200, body: { id: "ord_test_123" } }, }); } ```

Seed data through the same API the app uses, not by SQLite hacks unless you own the offline layer. Supabase row-level security must allow test service roles in staging only—never production keys in CI logs.

Use MSW or runner-native mocking at the fetch boundary so components stay unchanged. Tests that patch `global.fetch` inside the app bundle are fragile across Metro cache and release builds.

For streaming or LLM features, stub SSE and WebSocket endpoints with canned chunks. Flaky streaming tests are often timing on first token, not model quality—separate eval suites from UI smoke.

Check secrets into CI via platform stores, not repository env files. Rotated staging keys break E2E silently when tests still hit production-like URLs with expired tokens—fail fast with a dedicated health spec that runs before the matrix.

Make reliability visible

Pick one flake metric, one quarantine SLA, and one real-device tier to improve this sprint. Ask release managers whether confidence actually moved—not whether the badge turned green after retries.

Staff ownership turns E2E from a lottery into an instrument the team trusts when shipping Expo apps weekly. Link postmortems for store rejections or hotfixes back to missing or quarantined coverage so the organization learns.

Compare flake trends before and after SDK upgrades, navigation refactors, or new animation libraries. Regressions in test stability often precede user-visible jank by a sprint.

Share a monthly "mobile CI health" note with eng and product: top flakes fixed, top flakes remaining, minutes saved, specs deleted as low value. Transparency prevents the suite from becoming a haunted forest nobody edits.

Celebrate deleting redundant specs as much as adding coverage. Mobile teams drown when every historical bug gets a forever test without an owner or journey mapping.

Operational checklist for Expo E2E

Version-control a quarantine registry beside the test folder. Each entry lists spec name, owner, SLA date, last flake rate, and link to artifacts. Pull requests that add sleeps or retries must justify the synchronization gap in the description.

Define required checks explicitly: PR smoke on emulator, nightly full matrix on two OS versions, pre-release real-device spot check for push and payments. Document what is not covered so product does not assume store-ready proof from login-only smoke.

Align with sibling posts on performance budgets and API versioning—slow marketing sites and breaking API changes show up as mobile E2E timeouts before they show up as unit test failures.

Finally, delete specs that no longer map to user journeys. Zombie tests flake forever because nobody remembers the feature flag they guarded. Prune aggressively; coverage quality beats coverage count.

Invest in local reproduction scripts: one command that runs a single spec against staging with the same env vars as CI. Engineers fix flakes faster when reproduction does not require guessing runner secrets.

Pair E2E stabilization with contract tests on API responses mobile consumes. When backend shape drift causes UI spinners to hang, unit-level contract failure is cheaper than debugging a red Maestro flow at midnight.

Document environment parity in README: Node version, Expo SDK, runner CLI, and staging URL. Onboarding engineers should reproduce CI failures on day one, not after a week of local-only green runs.

Treat overtime flakes during release week as a signal to freeze scope, not to disable checks. Shortcuts taken under deadline pressure become permanent blind spots in checkout and auth. Schedule stabilization sprints after major SDK jumps the same way you schedule security patches. Both protect users when velocity is high.

Frequently asked questions

How many retries are acceptable in CI?
Zero in required checks for merge. Retries belong only in quarantine jobs while a spec is actively owned, with a cap and visible flake rate. Main pipeline retries teach teams to ignore red builds and hide synchronization debt until release week, when fixes are most expensive.
Is Expo Go enough for E2E?
Expo Go is fine for early UI experiments without custom native code. Production-like flows with push, deep links, proprietary native modules, or specific entitlements need development builds or release binaries in CI. Document which tier each spec requires so contributors do not chase unsupported paths.
What quarantine SLA should we use?
Two weeks for P0 flows, one sprint for others, unless release managers grant a written exception tied to a launch date. Past SLA, block the train or delete the spec. Unlimited quarantine is how teams ship without knowing whether checkout, login, or onboarding actually works on devices.
How many devices belong in CI?
At minimum one recent iOS and one recent Android representative of your user base, plus nightly rotation through one older OS version you still support. Emulators on every PR; real devices on nightly or pre-release. Match matrix to analytics share, not to the phones engineers happen to own.

Sources

Related service

iOS/Android mobile products with production architecture, store readiness, and backend integration.

View hire details


Published on October 20, 2026 by Berktug Berke Ates.