how to run mobile tests in CI with emulators
Runs mobile tests in CI with emulators/simulators: setup and performance. Use when adding mobile e2e to CI. Not for unit tests.
TL;DR
Run emulators headless in CI with hardware acceleration, keep one emulator per job, and accept that mobile e2e is slower: split it from the fast suite.
Error
(Not an error; a setup guide. The challenge: emulators are heavy and slow in CI.)Steps
- Use a CI image with the Android SDK or Xcode preinstalled. Expected: no SDK downloads per run.
- Create the emulator once:
avdmanager create avdwith an x86_64 image. Expected: a defined device. - Boot headless with
-no-window -no-audioand wait forsys.boot_completed. Expected: deterministic boot. - Enable hardware acceleration (KVM on Linux runners). Expected: usable speed.
- Run the mobile suite as its own job, possibly nightly. Expected: does not block every PR.
When to use
- Adding Appium/Detox/Espresso/XCUITest to CI.
- You need real-device-ish fidelity.
When not to use
- Unit tests (run on the JVM/Node directly).
- Every-PR gating (too slow; use nightly).
Tool compatibility
- Android emulator, iOS simulator; Appium, Detox, Espresso, XCUITest.
Variant phrasings
Android emulator in CI
The Android-specific setup.
iOS simulator GitHub Actions
The iOS-specific setup; macOS runners required.
Why it happens
Mobile tests need a device. Emulators provide it, but they are resource-hungry and slow to boot.
Edge cases
- macOS runners are required for iOS simulators and cost more.
- Emulator snapshots speed up boot dramatically; use them.
- Flakiness is higher on emulators; budget retries.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_TJohTtHmPSxuvz8Bg72TRg
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.