Skip to content

fix(e2e): improve Detox local debug build support#28965

Merged
abretonc7s merged 5 commits into
mainfrom
fix/detox-local-debug-builds
Apr 17, 2026
Merged

fix(e2e): improve Detox local debug build support#28965
abretonc7s merged 5 commits into
mainfrom
fix/detox-local-debug-builds

Conversation

@abretonc7s

@abretonc7s abretonc7s commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes several issues that prevent Detox e2e specs from running correctly in local debug builds:

  1. .detoxrc.js — Allow IOS_SIMULATOR env var to override the hardcoded iPhone 16 Pro device type. Falls back to the default when unset, so CI is unaffected.

  2. tests/helpers.js — launch detection — The original endsWith('debug') check never matched any Detox configuration name (ios.sim.main, ios.sim.flask, ios.sim.apiSpecs), so launchAppForDebugBuild was never called locally. This PR keeps the original endsWith('debug') check for backwards compatibility and adds !endsWith('.ci') as a fallback, so all non-CI configs (which use debug apps like ios.debug) correctly route through launchAppForDebugBuild. CI configs (ios.sim.main.ci, ios.sim.flask.ci) are unaffected — they still use launchAppWithRecovery with release apps.

  3. tests/helpers.js — packager URL — Use METRO_PORT_E2E / WATCHER_PORT for the packager URL instead of hardcoded 8081. METRO_PORT_E2E remains the primary source, WATCHER_PORT is a fallback for local .js.env config.

  4. tests/flows/general.flow.ts — Add WATCHER_PORT as fallback after METRO_PORT_E2E in dismissDevScreens, so local .js.env port config is respected.

  5. tests/jest.e2e.detox.config.js — Load .js.env via dotenv for shared infra vars (WATCHER_PORT, IOS_SIMULATOR) alongside .e2e.env. dotenv never overrides existing vars, so .e2e.env keys are unaffected.

Backwards compatibility

  • METRO_PORT_E2E remains the primary port source everywhere
  • CI configurations (*.ci) are unaffected — they still use release apps and recovery-based launch
  • IOS_SIMULATOR falls back to iPhone 16 Pro when unset

Changelog

CHANGELOG entry: null

Related issues

Fixes: TAT-2942

Manual testing steps

Feature: Detox local debug builds

  Scenario: Run Detox spec on custom simulator and port
    Given .js.env has WATCHER_PORT=8062 and IOS_SIMULATOR=mm-2
    And a debug build is installed on the mm-2 simulator

    When user runs yarn test:e2e:ios:debug:run tests/smoke/perps/perps-position.spec.ts
    Then Detox launches on mm-2 simulator (not iPhone 16 Pro)
    And Metro deep link uses port 8062 (not 8081)
    And dismissDevScreens connects to localhost:8062

  Scenario: CI behavior unchanged
    Given CI sets METRO_PORT_E2E and uses ios.sim.main.ci config

    When CI runs Detox specs
    Then launchAppWithRecovery is used (not launchAppForDebugBuild)
    And METRO_PORT_E2E is used for port (WATCHER_PORT ignored)

Screenshots/Recordings

Before

After

Pre-merge author checklist

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

Low Risk
Low risk: changes are limited to Detox/Jest e2e test configuration, but they do alter app launch routing and Metro port selection which could affect local/CI test stability if misconfigured.

Overview
Improves Detox local debug e2e runs by making the iOS simulator and Metro packager port configurable via env vars.

Detox now (1) allows IOS_SIMULATOR to override the default iOS device, (2) routes all non-*.ci configurations through the debug-build launch path in tests/helpers.js, and (3) uses METRO_PORT_E2E with WATCHER_PORT fallback for both deep-link packager URLs and dismissDevScreens.

Jest e2e config now loads .js.env after .e2e.env so shared infra vars like WATCHER_PORT are available at runtime without overriding test-specific env.

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

- .detoxrc.js: allow IOS_SIMULATOR env var to override device (falls
  back to iPhone 16 Pro)
- tests/helpers.js: use !endsWith('.ci') instead of endsWith('debug')
  so all non-CI configs use launchAppForDebugBuild; use METRO_PORT_E2E
  or WATCHER_PORT for packager URL
- tests/flows/general.flow.ts: add WATCHER_PORT as fallback after
  METRO_PORT_E2E for dismissDevScreens
- tests/jest.e2e.detox.config.js: load .js.env for shared infra vars
  (WATCHER_PORT, IOS_SIMULATOR) alongside .e2e.env
@abretonc7s abretonc7s requested a review from a team as a code owner April 17, 2026 09:24
@github-actions

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.

@metamaskbotv2 metamaskbotv2 Bot added the team-perps Perps team label Apr 17, 2026
@abretonc7s abretonc7s enabled auto-merge April 17, 2026 09:26
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Apr 17, 2026
Keep endsWith('debug') for backwards compatibility and add
!endsWith('.ci') to also route non-CI configs (e.g. ios.sim.main)
through launchAppForDebugBuild, since they use debug apps locally.
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Apr 17, 2026
Comment thread tests/jest.e2e.detox.config.js Outdated
Comment thread tests/helpers.js
…S_SIMULATOR

IOS_SIMULATOR is consumed by .detoxrc.js (Detox CLI, before Jest),
not at test runtime. Remove misleading reference from the comment.
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 17, 2026
racitores
racitores previously approved these changes Apr 17, 2026

@racitores racitores 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.

LGTM

Comment thread tests/jest.e2e.detox.config.js Outdated
dotenv first-loaded wins on collisions. Load .e2e.env before .js.env
so test accounts/flags are never overridden by infra vars.
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Apr 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeNetworkAbstractions, SmokeWalletPlatform, SmokeTrade, SmokeRamps, SmokeNetworkExpansion, SmokeMultiChainAPI, SmokeIdentity, SmokePerps, SmokePredictions, SmokeCard, SmokeSeedlessOnboarding, FlaskBuildTests
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: high
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
All four changed files are core E2E test infrastructure components that affect how every single E2E test is launched and executed:

  1. .detoxrc.js — The Detox configuration file that defines devices/simulators for ALL tests. The change adds IOS_SIMULATOR env var support to allow specifying a simulator by name. If this is misconfigured, no iOS tests will run at all.

  2. tests/helpers.js — The central test helper used by virtually all E2E tests. The launchApp method change modifies the logic for choosing between debug and release launch paths. The condition !config.configurationName.endsWith('.ci') means any non-CI config (local dev) now uses the debug launch path. This is a behavioral change that affects how the app is launched in every test.

  3. tests/flows/general.flow.ts — Used by FixtureHelper.ts (which underpins all fixture-based tests) and wallet.flow.ts. The dismissDevScreens function now falls back to WATCHER_PORT for the Metro server URL, which is critical for test startup.

  4. tests/jest.e2e.detox.config.js — The Jest configuration for all Detox E2E tests. Adding .js.env loading ensures WATCHER_PORT is available at runtime for the helpers above.

These changes are foundational to the entire E2E test pipeline. A regression in any of these files could cause all tests to fail silently (wrong app launched, wrong Metro port, wrong simulator). Running all test tags is the conservative and correct approach to validate the infrastructure changes work correctly across all test suites.

Performance Test Selection:
The changes are purely E2E test infrastructure (Detox config, test helpers, Jest config, general flow). They do not touch any app source code, UI components, controllers, or data loading paths that would affect app performance metrics. No performance tests are needed.

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 8523269. Configure here.

Comment thread tests/helpers.js
if (
config.configurationName.endsWith('debug') ||
!config.configurationName.endsWith('.ci')
) {

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.

CI API specs config bypasses recovery-based launch

High Severity

The ios.sim.apiSpecs Detox configuration is used on CI (via run-e2e-api-specs.yml / test:api-specs) with a release app (ios.${METAMASK_BUILD_TYPE}.release), but its name does not end with .ci. The new condition !config.configurationName.endsWith('.ci') causes it to route through launchAppForDebugBuild, which opens an expo-metamask://expo-development-client/ deep link — a URL scheme a release build does not handle. The API specs test calls withFixtures({ restartDevice: true }), which invokes TestHelpers.launchApp(), so this path is exercised on CI.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8523269. Configure here.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
12 value mismatches detected (expected — fixture represents an existing user).
View details

@abretonc7s abretonc7s added this pull request to the merge queue Apr 17, 2026
Merged via the queue into main with commit cc6197a Apr 17, 2026
114 of 115 checks passed
@abretonc7s abretonc7s deleted the fix/detox-local-debug-builds branch April 17, 2026 10:52
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 17, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.75.0 Issue or pull request that will be included in release 7.75.0 label Apr 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.75.0 Issue or pull request that will be included in release 7.75.0 risk-high Extensive testing required · High bug introduction risk size-S team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants