Skip to content

⚗ [POC] Android E2E tests using Playwright emulator#4212

Open
rgaignault wants to merge 7 commits intomainfrom
romanG/android-setup
Open

⚗ [POC] Android E2E tests using Playwright emulator#4212
rgaignault wants to merge 7 commits intomainfrom
romanG/android-setup

Conversation

@rgaignault
Copy link
Contributor

@rgaignault rgaignault commented Feb 19, 2026

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

  • Add test/e2e/android/ with global setup (emulator boot, adb reverse port forwarding, Chromium install),
    teardown, Playwright config, and a custom fixture that connects to the device
  • Integrate into the existing createTest framework: when ANDROID_E2E is set, tests use the Android fixture and
    run with the bundle setup only
  • Return localhost from getIp() for Android since the emulator reaches the host through adb reverse
  • Relax scroll position assertions in viewport tests to account for sub-pixel rounding on mobile DPI
  • Add yarn test:e2e:android script and a e2e-android CI job (need a local emulator)
  • Clean up comments in the new files

Test instructions

Prerequisites: Android Studio installed.

  1. 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"

  2. 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

  1. Checkout
    Checkout this branch

  2. Install, build, and run

  • yarn
  • yarn build
  • yarn build:apps
  • yarn test:e2e:android

If you already have an AVD with a different name:
ANDROID_AVD="Your_AVD_Name" yarn test:e2e:android

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@rgaignault rgaignault requested a review from a team as a code owner February 19, 2026 11:01
@rgaignault rgaignault marked this pull request as draft February 19, 2026 11:01
@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Feb 19, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 171.85 KiB 171.85 KiB 0 B 0.00%
Rum Profiler 4.29 KiB 4.29 KiB 0 B 0.00%
Rum Recorder 24.71 KiB 24.71 KiB 0 B 0.00%
Logs 56.66 KiB 56.66 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 128.38 KiB 128.38 KiB 0 B 0.00%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance

Pending...

🧠 Memory Performance

Pending...

🔗 RealWorld

@datadog-datadog-prod-us1-2
Copy link

datadog-datadog-prod-us1-2 bot commented Feb 19, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 77.13% (-0.06%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f939d06 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@rgaignault rgaignault force-pushed the romanG/android-setup branch 6 times, most recently from c9ebbc0 to da93c44 Compare March 2, 2026 15:18
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)
@rgaignault rgaignault force-pushed the romanG/android-setup branch from da93c44 to 83adaa1 Compare March 2, 2026 15:25
@rgaignault rgaignault marked this pull request as ready for review March 5, 2026 10:53
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +13 to +16
if (cachedDevice && cachedContext) {
try {
cachedContext.pages()
return { device: cachedDevice, context: cachedContext }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +56 to +58
const devices = await _android.devices()
if (devices.length > 0) {
return devices[0]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant