# End-to-End Testing with Maestro & Detox

> Automate full user journeys on simulators and real devices with Maestro, Detox, Patrol or native UI test frameworks, and run them in CI. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/mobile/e2e-testing
Last updated: 2026-11-28

Automate full user journeys on simulators and real devices with Maestro, Detox, Patrol or native UI test frameworks, and run them in CI.

Advanced · about 7 hours · difficulty 4/5

Learn first: [Component & UI Testing](https://www.internhack.in/roadmaps/tracks/mobile/component-testing)

End-to-end (E2E) tests install a real build and drive it like a user: launch, tap, type, scroll and assert. They catch problems nothing else does (native crashes, broken deep links, permission dialogs, release-only bugs) but they are slow and can be flaky, so keep the suite small and focused on critical journeys.

### What to cover

Pick five to ten journeys that must never break: sign up, log in, the main purchase or create flow, logout, and a deep link into a detail screen.

### Tools

- **Maestro:** readable YAML flows, works with React Native, Flutter and native apps, and tolerates timing by waiting automatically.

```
appId: com.example.shop
---
- launchApp
- tapOn: "Sign in"
- inputText: "test@example.com"
- assertVisible: "Welcome back"
```

- **Detox:** gray-box testing for React Native written in JavaScript; it synchronises with the app's JS thread and network so tests wait for idleness.
- **Patrol** or **integration_test:** Flutter options; Patrol can also tap native permission dialogs.
- **Espresso/UI Automator** and **XCUITest** for native apps.

### Fighting flakiness

- Use stable selectors (test ids or accessibility labels), never coordinates.
- Seed a known backend state or use a dedicated test environment.
- Avoid fixed sleeps; rely on the framework's waiting.
- Record videos and screenshots on failure to debug CI runs.

### Running in CI

Run E2E on every pull request against a simulator or emulator, and periodically on real device farms (Firebase Test Lab, BrowserStack, Maestro Cloud, EAS Workflows) to cover different OS versions.

**Good enough to move on:** your two most important user journeys run automatically in CI on a release-like build.

## Key concepts

- **Choosing critical journeys**
- **Maestro flows**
- **Detox for React Native**
- **Patrol and integration_test**: Flutter
- **Stable selectors and test ids**
- **Test data and environments**
- **Reducing flakiness**
- **Device farms**

## Mini project

Write Maestro flows for sign-up, adding an item to a cart and checking out, then run them in a CI job against an emulator with video recording on failure.

## Check yourself

Your E2E test passes locally but fails one run in five on CI. List three likely causes and how you would investigate them.

## Free resources

- [Maestro documentation](https://docs.maestro.dev/) (Maestro)
- [Detox documentation](https://wix.github.io/Detox/) (Wix)
- [Flutter: Integration testing](https://docs.flutter.dev/testing/integration-tests) (Flutter)

Previous: [Component & UI Testing](https://www.internhack.in/roadmaps/tracks/mobile/component-testing) · Next: [Mobile Accessibility](https://www.internhack.in/roadmaps/tracks/mobile/accessibility)

## More in Testing Mobile Apps

- [Unit Testing App Logic](https://www.internhack.in/roadmaps/tracks/mobile/unit-testing)
- [Component & UI Testing](https://www.internhack.in/roadmaps/tracks/mobile/component-testing)
- [End-to-End Testing with Maestro & Detox](https://www.internhack.in/roadmaps/tracks/mobile/e2e-testing)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Mobile App Developer Roadmap](https://www.internhack.in/roadmaps/tracks/mobile)
