⚗ [POC] Android E2E tests using Playwright emulator#4212
⚗ [POC] Android E2E tests using Playwright emulator#4212rgaignault wants to merge 7 commits intomainfrom
Conversation
Bundles Sizes Evolution
🚀 CPU PerformancePending... 🧠 Memory PerformancePending... |
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: f939d06 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfe49e214f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
c9ebbc0 to
da93c44
Compare
Setup Android E2E testing using Playwright's experimental Android API with an emulator running on a macOS Sonoma GitLab runner. - Boot Android emulator in globalSetup, teardown in globalTeardown - Install recent Chromium (v147) via snapshot builds to replace outdated system Chrome (v113) - Reuse device connection and browser context across tests for performance - Clean up service workers between tests to prevent stale state - Wire Android fixture into existing createTest() framework - All existing e2e scenarios run on Android with bundle setup - Fix scroll test sub-pixel rounding on mobile DPI - 237/249 tests pass, ~3 flaky (pass on retry)
da93c44 to
83adaa1
Compare
…emulator timing" This reverts commit d4e6b46.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f939d065ec
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (cachedDevice && cachedContext) { | ||
| try { | ||
| cachedContext.pages() | ||
| return { device: cachedDevice, context: cachedContext } |
There was a problem hiding this comment.
Create a fresh BrowserContext per Android test
getOrCreateContext() reuses a single BrowserContext for every Android test, but the shared teardown path only clears cookies, so origin-scoped state like localStorage/IndexedDB/permissions survives between cases. That makes Android E2E order-dependent and can hide or create failures when one test leaves client state that a later test implicitly expects to be absent (for example, scenarios that read/write localStorage-backed config/session data).
Useful? React with 👍 / 👎.
| const devices = await _android.devices() | ||
| if (devices.length > 0) { | ||
| return devices[0] |
There was a problem hiding this comment.
Target a specific Android device instead of the first one
The fixture attaches to _android.devices()[0], which is nondeterministic when more than one phone/emulator is connected. In that case Playwright can run against a different device than the one started and prepared in global setup, so port-reverse setup and Chromium installation may apply to one target while tests execute on another, causing intermittent navigation/intake failures in multi-device environments.
Useful? React with 👍 / 👎.
Motivation
We currently run E2E tests on desktop browsers only. We have no coverage for mobile browsers, which behave
differently (touch events, viewport handling, DPI scaling, etc.). This POC explores running our existing E2E
tests on an Android emulator using Playwright's native Android support.
Changes
teardown, Playwright config, and a custom fixture that connects to the device
run with the bundle setup only
Test instructions
Prerequisites: Android Studio installed.
Add Android SDK tools to your PATH (add to ~/.zshrc for persistence)
export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH="$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools"
Create an AVD (skip if you already have one)
sdkmanager "system-images;android-35;google_apis;arm64-v8a"
avdmanager create avd -n test_device -k "system-images;android-35;google_apis;arm64-v8a"
this also can be done in the UI
Checkout
Checkout this branch
Install, build, and run
If you already have an AVD with a different name:
ANDROID_AVD="Your_AVD_Name" yarn test:e2e:android
Checklist