feat(config): accept an object for launch args

Merged
LU
1d ago
+1138-100

What and why

Part of #1855, the app: { launchArguments: { AppleLocale: 'fr_FR' } } row.

  • app.launchArguments now supports { name: value } as well as the list of strings. Detox and Maestro suites have a map to port, and AppleLanguages: ['fr'] is easier to write than '-AppleLanguages', '(fr)'.
  • A value is a string, number, boolean, or list of strings. Core checks the shape at config load: packages/core/src/config/app.ts.
  • mobile() writes each entry for its platform in packages/mobile/src/launch-arguments.ts: -name value on iOS, and on Android an am start extra of the value's type (--ez, --ei, --ef, --es, --esa), so the app reads it with the matching Intent getter. An object with one of Apple's keys on an Android target fails at config load.
  • device.openApp(app, { launchArguments }) takes the same object form and checks it the way config load does, with INVALID_ARGUMENT. The shape check is checkLaunchArguments, exported from @e2e-dev/core/engine.
  • Android cannot carry every list: am start --esa splits on each comma, keeps the backslash before an escaped one, and reads an empty value as one empty item. An object's list on Android is refused when it is empty or an item is empty, holds a comma, or ends in a backslash. An iOS string value goes out as a plist string, so '(draft)' reaches the app as text, not an array. Core refuses a number beyond 2^53 and a NUL character.
  • The list still goes to the launch command as it did, with three changes, each a loud failure: the config error for a non-string list item has new text, a list item with a NUL character now fails at config load, and a list passed to device.openApp is now shape-checked.
  • The engine contract stays backward compatible. EngineAppInfo.launchArguments is still readonly string[], so an engine that spreads it keeps working, including published @e2e-dev/mobile 0.12.8, whose peer ranges admit this core. The object goes to a new field, EngineAppInfo.launchArgumentValues, only for an engine that declares launchArgumentValues: true (defineEngine, the engine manifest, and its schema). Any other engine gets INVALID_CONFIG at config load and never sees the object. mobile() and desktop() opt in.

IOS changes:

// before and still valid
launchArguments: ['-AppleLanguages', '(fr)', '-AppleLocale', 'fr_FR'],

// new
launchArguments: { AppleLanguages: ['fr'], AppleLocale: 'fr_FR' },

Android changes:

// before and still valid
launchArguments: ['--ez', 'e2e', 'true'],

// new
launchArguments: { e2e: true },

^ this change wasn't asked for in this proposed API but I thought it'd be a good quality of life improvement for the Android side. Let me know if it should be taken out 👍

Issue

feature: https://github.com/e2e-inc/e2e/issues/1855 device and app app: { launchArguments: { AppleLocale: 'fr_FR' } }

Verified

Ran it locally: yes

  • Re-run after the engine contract review, Node 24.19.0, at 7f4a2f21 (5a7b87a1 after it changes only docs and the changeset; docs:check and check:changeset-bumps green there):

    • pnpm check green. pnpm test green (8558 tests across 22 vitest runs, none failed).

    • The reviewer's case against the packed @e2e-dev/core and e2e in a scratch project:

      EngineList{ AppleLocale: 'fr_FR', AppleLanguages: ['fr'] }
      custom engine whose init spreads app.launchArgumentse2e run passes, init gets ["-AppleLocale","fr_FR","-AppleLanguages","(fr)"]INVALID_CONFIG at config load, exit 2, init never runs
      published @e2e-dev/mobile@0.12.8e2e list loadsINVALID_CONFIG at config load, exit 2

      tsc accepts the unchanged [...(info.app.launchArguments ?? [])] against the new declaration.

    • New tests: engine-protocol.test.ts "hands an engine that predates the object form a list it can spread, and refuses an object at config load" and "carries the object form to an engine that declares launchArgumentValues" (over the loopback protocol). The mobile and desktop engine tests assert the opt-in; removing either launchArgumentValues: true fails them.

  • On devices, with a hand-run check that lived in the mobile benchmark while this was developed and is no longer in the PR (CI never ran it, and dumpsys shows only (has extras) on Android): an iPhone simulator (iOS 26.5) and a Pixel 7 emulator, Release builds, the object and the list forms producing the same launch. The simulator process ran as e2eBenchmark -AppleLanguages (fr) -AppleLocale fr_FR; the emulator's launch intent carried the extras. The Android half ran again after 0aae6136 with --ez.

  • The full gate on the final tree, rebased on main: pnpm check green, translation check included (the docs/ja and docs/zh pages carry the changed code blocks and the new heading, their prose untouched); pnpm test under Node 24 green across every package (the e2e package alone: 4870 passed, 11 skipped).

  • Re-run after the last review, Node 24.19.0. The benchmarks and device runs below ran at 209b49fa plus the last two commits' changes, before the rebase on main. After the rebase, pnpm check and pnpm test ran again at 3822804f, both green (8479 tests across 22 vitest runs):

    • Before the rebase: pnpm check green. pnpm test green (8062 tests across 22 vitest runs). pnpm test:testbed 600 passed, 1 skipped. pnpm test:web-benchmark 95 passed.

    • CI=1 pnpm --filter @e2e-dev/web-benchmark run test:agent --strict-cache: 26 passed, 8 failed. Same 8 fail on the merge base 6fdb1c27: 5 steps have no recording and call the model (no key on this machine), 3 planted-bug judgments the same way.

    • pnpm test:mobile-benchmark, Release builds of the app: iPhone 17 Pro simulator (iOS 26.5) 61 passed, 1 skipped. Pixel 7 emulator (Android 36, google_apis_playstore) 59 passed, 1 failed, 1 skipped. The failure is device.e2e.ts "a denied prompt recovers once the permission is granted outside" (alert dismiss did not dismiss the visible alert). No launch arguments in it, and it flakes the same on the merge base with the same APK and emulator (2 of 4 runs fail there, 2 of 3 here).

    • A launch with an object from the config and from device.openApp({ relaunch: true, launchArguments }) on both devices. iOS process (ps):

      config:  -AppleLanguages (fr) -AppleLocale fr_FR -flag NO -on YES -retries 3 -negative "-1" -spaced "a b" -paren "(draft)" -cdn "//cdn" -blank "" -tags ("", a, "x,y", "//cdn.example/assets")
      openApp: -note "-1" -count 7
      

      Android am start (agent-device's adb calls, recorded through a wrapper):

      config:  --ez on true --ei retries 3 --ei max 2147483647 --el big 2147483648 --ef ratio 1.5 --es spaced 'a b' --es paren '(draft)' --es empty '' --esa tags 'a,b c'
      openApp: --es note -1 --ei count 7
      
  • unit tests:

$ pnpm --filter @e2e-dev/mobile exec vitest run tests/unit/launch-arguments.test.ts
âś“ launchArgumentList > passes a list through as given and sends nothing for none
âś“ launchArgumentList > spells an object as iOS process arguments
âś“ launchArgumentList > quotes a string NSUserDefaults would otherwise read as a plist, as a value and as a list item
âś“ launchArgumentList > spells an object as am start extras of each value's type
âś“ assertLaunchArgumentsFor > refuses Apple's arguments in an object on Android, and nothing else
âś“ assertLaunchArgumentsFor > refuses a list am start would read back changed on Android, and takes any list on iOS
âś“ assertLaunchArgumentsFor > fails a launch a test asked for with INVALID_ARGUMENT
âś“ launchArgumentsForOpen > checks the declared shape and the platform rules, and leaves out an undefined value
Tests  8 passed (8)

$ pnpm --filter @e2e-dev/mobile exec vitest run tests/unit/engine.test.ts -t "launch"
âś“ manifest > refuses an iOS launch argument in an object on an Android target, and passes a list through
âś“ device fixture > spells a launch-argument object for the platform on every fresh launch of the pinned app, and sends nothing for an empty object
âś“ device fixture > launches any app with its own arguments, a list or an object spelled for the platform, and permissions set on that app by name
âś“ device fixture > refuses openApp launch arguments of the wrong shape, or ones Android cannot carry, before any device command

$ pnpm --filter e2e exec vitest run tests/unit/config.test.ts -t "launch arguments"
âś“ resolveConfig > takes launch arguments as an object of name to string, number, boolean, or list of strings, and leaves out an undefined value

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and the valid fixture (launchArgumentValues is a plain boolean, so the invalid fixture needs no change).
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/core, @e2e-dev/mobile, and @e2e-dev/desktop. @e2e-dev/web has no change: it never receives launch arguments.