Skip to content

test: adapt FixureHelper to run with appium and local runs#29796

Merged
christopherferreira9 merged 14 commits into
mainfrom
cferreira/adapt-fixture-helper
May 21, 2026
Merged

test: adapt FixureHelper to run with appium and local runs#29796
christopherferreira9 merged 14 commits into
mainfrom
cferreira/adapt-fixture-helper

Conversation

@christopherferreira9

@christopherferreira9 christopherferreira9 commented May 6, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adapts the FixtureHelper (withFixtures) to work properly with appium and playwright.

Main changes:

  • launchApp utility inside withFixtures now sends launchArgs so that FixtureServer and other resources can properly be used
  • MockServer is completely tool agnostic
  • App interaction is now segregated in specific handlers for adb and xcrun with an abstract CommandHandler
    • These are also exposed via test callback so that individual tests can interact with the device to clear app data, uninstall, install and so on
  • Android amulator name is now automatically derived from its friendly name. Eg: PIXEL_XL_API_34 is not translated in the proper serial as emulator-5554
  • FixtureServer now waits for an initial request to avoid early test start
  • Tests now only start once Metro has finished loading. This prevents early fast fails where metro would take longer to load than the test would start.
    1. FixtureServer now counts completed GET /state.json requests.
    2. Before launching the app in Appium mode, withFixtures creates a waiter with fixtureServer.waitForNextStateRequest().
    3. Then PlaywrightUtilities.launchApp(...) launches the app with the fixture/mock/command server launch args.
    4. The app loads JS from Metro, runs the E2E bootstrap, and requests /state.json.
    5. When that request finishes, FixtureServer resolves the waiter.
    6. Only then does withFixtures continue to dismiss dev screens and run the actual test body.
  • Appium server log level has been bumped to INFO to avoid clutter
  • A boilerplate test using withFixtures has been added to be used as a guide for debugging
  • Implemented different conditions to run tests locally on emulator:
    • buildPath is not provided - Framework checks for installed app, deletes app data and launches the app. Throws if the app is not installed.
    • buildPath is provided - App is uninstalled and installed back. Throws if the artifact does not exist.

Introduction of test shims:

This PR also adds a Playwright-only Node shim so FixtureBuilder can load in Playwright without changing app runtime behavior.
We need this shim mechanism because some app dependencies patch CommonJS packages to call native modules such as @metamask/native-utils. Those calls are valid in the mobile app, but Playwright loads the same dependency graph in Node where React Native/Nitro native modules are unavailable.

Changelog

CHANGELOG entry:

Related issues

Fixes:

Manual testing steps

N/A

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Touches core E2E test harness startup/cleanup (app launching, fixture boot gating, and device commands) across both Detox and Appium, so failures could block large portions of the test suite despite being test-only code.

Overview
Adds first-class Appium/Playwright support to withFixtures. App restarts now branch by framework: Detox continues using TestHelpers.launchApp, while Appium launches via PlaywrightUtilities.launchApp with resolved launchArgs (fallback ports, URL blacklist, mock/command/WS ports), optionally clears local app data, and waits for the app’s first /state.json fetch before running the test body.

Introduces local device management commands for tests. Adds DeviceCommandHandler (Android adb, iOS xcrun simctl) and exposes it to test callbacks via TestSuiteParams.deviceCommands, plus updates types accordingly.

Improves Playwright Node compatibility and local ergonomics. Registers a Node-only CommonJS shim for @metamask/native-utils in Playwright entrypoints, adds Playwright-specific dev-screen dismissal flow, lowers Appium server log level to INFO, tweaks performance specs/config to use new activation/fixture patterns, and adds unit coverage for PlaywrightUtilities.launchApp and device command handlers.

Reviewed by Cursor Bugbot for commit c658438. Bugbot is set up for automated code reviews on this repo. Configure here.

@christopherferreira9 christopherferreira9 added team-qa QA team no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed labels May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Comment thread .yarn/patches/@ethereumjs-util-npm-9.1.0-7e85509408.patch Outdated
@christopherferreira9 christopherferreira9 marked this pull request as ready for review May 18, 2026 15:37
@christopherferreira9 christopherferreira9 requested a review from a team as a code owner May 18, 2026 15:37
Comment thread tests/framework/fixtures/FixtureHelper.ts
Comment thread tests/performance/mm-connect/connection-evm-account.spec.ts Outdated
Comment thread tests/playwright.config.ts
Comment thread tests/framework/PlaywrightUtilities.ts
Comment thread tests/performance/mm-connect/connection-evm-account.spec.ts Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are to the Playwright/Appium test infrastructure itself (the framework that runs performance tests), not to app code that would affect performance metrics. The playwright.config.ts changes point to a demo fixture test, not actual performance measurement tests. The tests/performance/mm-connect/connection-evm-account.spec.ts change is a minor refactor (using PlaywrightGestures.activateApp instead of PlaywrightUtilities.launchApp). No app source code was changed that would affect rendering, data loading, or startup performance. Performance test tags should not be selected.

Performance Test Selection:
No performance impact detected

View GitHub Actions results

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c658438. Configure here.

Comment thread tests/playwright.config.ts
@sonarqubecloud

Copy link
Copy Markdown

@christopherferreira9 christopherferreira9 added this pull request to the merge queue May 21, 2026
Merged via the queue into main with commit 2114fc0 May 21, 2026
148 of 158 checks passed
@christopherferreira9 christopherferreira9 deleted the cferreira/adapt-fixture-helper branch May 21, 2026 14:55
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed size-XL team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants