Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8a0bd97
feat(config): accept an object for launch args
luke-h1 Nov 17, 2026
57618dc
fix(mobile): type the Android extras an object spells, and take one o…
luke-h1 Nov 17, 2026
fd4592b
fix(mobile): refuse what a launch command would read back changed
luke-h1 Nov 17, 2026
d6ad30d
chore(mobile): widen the Apple argument list and drop the hand-run la…
luke-h1 Nov 17, 2026
8ce114c
docs(ja, zh): mirror the launch-argument code blocks
luke-h1 Nov 17, 2026
b271853
fix(core): let a launch-argument value be undefined, and name the bad…
luke-h1 Nov 17, 2026
7c9a6ac
docs: name the launch-argument object in the translated tables, and t…
luke-h1 Nov 17, 2026
ed90f00
fix(mobile): quote iOS launch argument values that start with a dash
luke-h1 Nov 19, 2026
012f20d
refactor(core): resolve launch arguments without undefined values
luke-h1 Nov 19, 2026
a27d861
refactor: narrow the scalar check and simplify the android list check
luke-h1 Nov 19, 2026
bdab01d
docs(migrate): say where Detox puts launch args on Android
luke-h1 Nov 19, 2026
09e4ffa
chore: trim the launch-arguments changeset to what users see
luke-h1 Nov 19, 2026
bc210fe
fix(mobile): raise the e2e peer floor to the first release with check…
luke-h1 Nov 21, 2026
4e94356
feat(desktop): spell object launch args as user defaults
luke-h1 Nov 21, 2026
80eb27a
test(desktop): cover the appPath launch with an object
luke-h1 Nov 21, 2026
d6f694f
refactor(core): share the NSUserDefaults spelling as appleUserDefaults
luke-h1 Nov 22, 2026
db2dac9
fix(core): quote // plist items and refuse a dashed launch argument name
luke-h1 Nov 23, 2026
2ce1c16
fix(core): tell the user to remove the dash from a launch argument name
luke-h1 Nov 23, 2026
6b43448
docs: show the list form for apps that read raw process arguments
luke-h1 Nov 23, 2026
7f4a2f2
fix(core): keep EngineAppInfo.launchArguments a list, send objects th…
luke-h1 Nov 23, 2026
5a7b87a
docs: scope the launch-argument example to Apple engines, and say ope…
luke-h1 Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/launch-arguments-object.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'e2e': patch
'@e2e-dev/core': patch
'@e2e-dev/mobile': patch
'@e2e-dev/desktop': patch
---

`app.launchArguments` and `device.openApp({ launchArguments })` also take an object of argument name to string, number, boolean, or list of strings, such as `{ AppleLanguages: ['fr'], AppleLocale: 'fr_FR' }`. Write a name without its leading dash: `{ AppleLocale: 'fr_FR' }`, not `{ '-AppleLocale': 'fr_FR' }`, which fails at config load. On iOS, `mobile()` sends each entry as `-name value`, and so does `desktop()` on macOS. On Android, each entry is an `am start` extra of the value's type: `--es`, `--ez`, `--ei` (`--el` beyond Java's `int`), `--ef`, or `--esa` for a list. An Android object fails when it holds one of Apple's arguments, such as `AppleLocale`, or a list that `am start` would change: an empty list, or an item that is empty, holds a comma, or ends in a backslash. A list of strings still goes to the launch command as given. `EngineAppInfo.launchArguments` stays a list of strings. An engine that declares `launchArgumentValues: true` receives an object in `EngineAppInfo.launchArgumentValues`; for any other engine an object fails at config load. `@e2e-dev/core/engine` exports the types, the shape check `checkLaunchArguments`, and `appleUserDefaults`, which spells an object as `-name value` arguments for an iOS or macOS app.
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
2 changes: 1 addition & 1 deletion docs/cs/mobile.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jazyk:
engine: mobile({ platform: 'ios' }),
app: {
bundleId: 'com.example.app',
launchArguments: ['-AppleLanguages', '(fr)', '-AppleLocale', 'fr_FR'],
launchArguments: { AppleLanguages: ['fr'], AppleLocale: 'fr_FR' },
},
}
```
Expand Down
4 changes: 3 additions & 1 deletion docs/desktop.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ It checks agent-desktop, both permissions, and the `appPath` build.
Set the target's `app.appPath` to a built `.app` bundle. Or set
`app.bundleId` to an installed app's bundle id or name, such as
`com.apple.calculator`. With both, the `appPath` build is launched, and its
bundle id must be `bundleId`. `app.launchArguments` go to every launch.
bundle id must be `bundleId`. `app.launchArguments` go to every launch. An
object entry becomes `-name value`, as on iOS, so
`{ AppleLanguages: ['fr'] }` opens the app in French.

The app gets only these variables of the run's environment: `HOME`, `USER`,
`LOGNAME`, `SHELL`, `PATH`, `TMPDIR`, `LANG`, `LC_*`, and
Expand Down
2 changes: 1 addition & 1 deletion docs/es/mobile.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ destino por idioma:
engine: mobile({ platform: 'ios' }),
app: {
bundleId: 'com.example.app',
launchArguments: ['-AppleLanguages', '(fr)', '-AppleLocale', 'fr_FR'],
launchArguments: { AppleLanguages: ['fr'], AppleLocale: 'fr_FR' },
},
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/fr/mobile.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pour ce lancement. L'appareil garde sa propre langue. Ajoutez une cible par lang
engine: mobile({ platform: 'ios' }),
app: {
bundleId: 'com.example.app',
launchArguments: ['-AppleLanguages', '(fr)', '-AppleLocale', 'fr_FR'],
launchArguments: { AppleLanguages: ['fr'], AppleLocale: 'fr_FR' },
},
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/hi/mobile.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ iOS पर लॉन्च आर्ग्युमेंट से उस ल
engine: mobile({ platform: 'ios' }),
app: {
bundleId: 'com.example.app',
launchArguments: ['-AppleLanguages', '(fr)', '-AppleLocale', 'fr_FR'],
launchArguments: { AppleLanguages: ['fr'], AppleLocale: 'fr_FR' },
},
}
```
Expand Down
12 changes: 10 additions & 2 deletions docs/ja/migrate/detox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ export default {
{
name: 'ios',
engine: mobile({ platform: 'ios' }),
app: { bundleId: 'com.example.app', appPath: 'ios/build/MyApp.app' },
app: {
bundleId: 'com.example.app',
appPath: 'ios/build/MyApp.app',
launchArguments: ['-mockServer', 'http://localhost:9001'],
},
},
{
name: 'android',
engine: mobile({ platform: 'android' }),
app: { bundleId: 'com.example.app', appPath: 'android/app/build/outputs/apk/debug/app-debug.apk' },
app: {
bundleId: 'com.example.app',
appPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
launchArguments: ['--es', 'mockServer', 'http://localhost:9001'],
},
},
],
workers: 1,
Expand Down
2 changes: 1 addition & 1 deletion docs/ja/mobile.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ iOS では、起動引数でその起動時のアプリの言語と地域を設
engine: mobile({ platform: 'ios' }),
app: {
bundleId: 'com.example.app',
launchArguments: ['-AppleLanguages', '(fr)', '-AppleLocale', 'fr_FR'],
launchArguments: { AppleLanguages: ['fr'], AppleLocale: 'fr_FR' },
},
}
```
Expand Down
11 changes: 10 additions & 1 deletion docs/ja/reference/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ targets: [
| [`linkBase`](#linkbase) | `string` | - |
| [`identity`](#identity) | `string` | アプリから導出 |
| [`environment`](#environment) | `'test' \| 'staging' \| 'production'` | `'test'` または `'production'` |
| [`launchArguments`](#launcharguments) | `string[]` | - |
| [`launchArguments`](#launcharguments) | `string[] \| Record<string, LaunchArgumentValue>` | - |
| [`permissions`](#permissions) | `Record<string, AppPermissionState>` | - |
| [`command`](#command) | `CommandConfig` | - |
| [`readyUrl`](#readyurl) | `string` | `url` |
Expand Down Expand Up @@ -417,6 +417,15 @@ environment: 'staging', // default: 'test' for a local host or no URL, else 'pro
launchArguments: ['-e2e', 'YES'],
```

```ts
launchArguments: { AppleLanguages: ['fr'], AppleLocale: 'fr_FR', e2e: true },
Comment thread
luke-h1 marked this conversation as resolved.
Resolved
```

```ts
type LaunchArgumentValue = string | number | boolean | readonly string[];
type LaunchArguments = readonly string[] | Readonly<Record<string, LaunchArgumentValue | undefined>>;
```

ビルドモードを選ぶ引数は、アプリの内容を変えます。モードごとに独自の `identity` を指定してください。

#### `permissions`
Expand Down
54 changes: 53 additions & 1 deletion docs/ja/reference/engine.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ export interface Engine {
* for the target before anything is prepared.
*/
readonly selectsDevice?: boolean;
/**
* The engine reads the object form of `app.launchArguments` from
* `EngineAppInfo.launchArgumentValues`. Without it the harness refuses an
* object at config load.
*/
readonly launchArgumentValues?: boolean;
/** capability: keyboard - requires observation. Input to whatever holds focus; see `EngineKeyboard`. */
readonly keyboard?: EngineKeyboard;
/**
Expand Down Expand Up @@ -1340,6 +1346,18 @@ export interface EngineAppCheckInfo {

/** A permission's state when the app launches: held, refused, or not asked for yet, so the OS asks again. */
export type AppPermissionState = 'grant' | 'deny' | 'reset';

/** One value in the object form of `launchArguments`; the engine spells it for its platform. */
export type LaunchArgumentValue = string | number | boolean | readonly string[];

/** A target's launch arguments: the strings the launch command takes, or an object of argument name to value. */
export type LaunchArguments = readonly string[] | Readonly<Record<string, LaunchArgumentValue | undefined>>;

/** The object form after the shape check: the `undefined` entries are gone. */
export type LaunchArgumentValues = Readonly<Record<string, LaunchArgumentValue>>;

/** Launch arguments after the shape check: a list of strings, or the object form. */
export type ResolvedLaunchArguments = readonly string[] | LaunchArgumentValues;
```

#### `EngineAppInfo`
Expand Down Expand Up @@ -1375,8 +1393,14 @@ export interface EngineAppInfo {
readonly bundleId?: string;
/** The build to install, as the target declared it; relative to `projectRoot`. */
readonly appPath?: string;
/** Arguments every fresh launch passes the app. */
/** Arguments every fresh launch passes the app, when the target declared them as a list of strings. */
readonly launchArguments?: readonly string[];
/**
* Arguments every fresh launch passes the app, when the target declared
* them as an object; only an engine that declares `launchArgumentValues`
* receives one.
*/
readonly launchArgumentValues?: LaunchArgumentValues;
/** Permissions the app holds, by name; what each state means is the engine's (a device sets them before every fresh launch). */
readonly permissions?: Readonly<Record<string, AppPermissionState>>;
}
Expand Down Expand Up @@ -1574,6 +1598,8 @@ export class InfrastructureError extends E2EError {
| [`pollCondition`, `Deadline`](#pollcondition) | `Promise<void>`, `Deadline` |
| [`validateJsonValue`](#validatejsonvalue) | `void` |
| [`rejectUnknownKeys`](#rejectunknownkeys) | `void` |
| [`checkLaunchArguments`](#checklauncharguments) | `ResolvedLaunchArguments \| undefined` |
| [`appleUserDefaults`](#appleuserdefaults) | `readonly string[]` |
| [`rejectUnknownOptions`](#rejectunknownoptions) | `void` |
| [`obj`](#obj) | `WithoutUndefined<T>` |
| [`raceAbort`, `withTimeout`, `withinCleanupBudget`](#timing-helpers) | `Promise<T>`, `Promise<T>`, `Promise<void>` |
Expand Down Expand Up @@ -1733,6 +1759,32 @@ rejectUnknownKeys('web()', options, ['browser', 'viewport']);
- 入力ミスと考えられる近いキーがあれば、メッセージにそのキーを示します。なければ既知のキーを示します。
- テストからフィクスチャメソッドに渡すオブジェクトでは、`code` に `'INVALID_ARGUMENT'` を指定します。

#### `checkLaunchArguments`

```ts
export function checkLaunchArguments(
label: string,
declared: unknown,
code?: 'INVALID_CONFIG' | 'INVALID_ARGUMENT', // default: 'INVALID_CONFIG'
): ResolvedLaunchArguments | undefined;
```

```ts
const launchArguments = checkLaunchArguments('device.openApp({ launchArguments })', options.launchArguments, 'INVALID_ARGUMENT');
// device.openApp({ launchArguments }).env must be a string, number, boolean, or array of strings, got null
```

#### `appleUserDefaults`

```ts
export function appleUserDefaults(launchArguments: ResolvedLaunchArguments): readonly string[];
```

```ts
appleUserDefaults({ AppleLanguages: ['fr', 'en-GB'], e2e: true, offset: -1, mode: '(draft)' });
// ['-AppleLanguages', '(fr, en-GB)', '-e2e', 'YES', '-offset', '"-1"', '-mode', '"(draft)"']
```

#### `rejectUnknownOptions`

フィクスチャメソッドやマッチャーが受け付けないオプションキーを拒否します。JavaScript の呼び出し元が未対応オプションを渡しても、デフォルトのまま動かず、失敗するようにします。
Expand Down
25 changes: 21 additions & 4 deletions docs/ja/reference/mobile.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,21 @@ export default {
```

- iOS は引数をアプリのプロセス(`ProcessInfo.processInfo.arguments`)に渡します。Android は `am start` に追加するため、`['--ez', 'e2e', 'true']` は真偽値の Intent extra になります。

```ts title="e2e.config.ts"
export default {
targets: [
{
name: 'iphone',
engine: mobile({ platform: 'ios' }),
app: {
bundleId: 'com.example.app',
launchArguments: ['-flag', 'false', '-title', 'a b'],
},
},
],
} satisfies E2EConfig;
```
- 各権限の状態は `grant`、`deny`、`reset` です。iOS の `deny` は拒否を記録し、確認画面を出さずにアプリへ拒否を返します。Android では権限を取り消し、次にアプリが要求すると OS が再度確認します。
- アプリを先に開かず、起動前にアプリ名を指定して権限を設定します。iOS は権限が変更された実行中のアプリを終了し、Android は権限を取り消されたアプリを終了するためです。
- ウォームアップでは起動引数を渡さず、権限にも触れません。
Expand Down Expand Up @@ -730,6 +745,7 @@ openApp(app: string, options?: OpenAppOptions): Promise<void>;
```ts
await device.openApp('Settings');
await device.openApp('com.example.app', { relaunch: true, permissions: { camera: 'grant' } });
await device.openApp('com.example.app', { relaunch: true, launchArguments: { AppleLocale: 'fr_FR' } });
```

- agent-device は `scheme:rest` 形式をすべて URL として開くため、リンクはデバイスへ渡す前に拒否します。
Expand Down Expand Up @@ -1149,11 +1165,12 @@ export interface OpenAppOptions {
/** Terminate the app first, so it starts fresh; without it a running app is brought forward as it is. */
readonly relaunch?: boolean;
/**
* Arguments this launch hands the app: its process arguments on iOS,
* `am start` arguments on Android. Replaces the target's `app.launchArguments`
* for a relaunch of the pinned app.
* Arguments this launch hands the app, a list or an object like
* `app.launchArguments`: its process arguments on iOS, `am start`
* arguments on Android. Replaces the target's `app.launchArguments` for a
* relaunch of the pinned app.
*/
readonly launchArguments?: readonly string[];
readonly launchArguments?: LaunchArguments;
/**
* Permissions the app holds before this launch, each granted, denied, or
* reset. Replaces the target's `app.permissions` for a relaunch of the
Expand Down
4 changes: 2 additions & 2 deletions docs/migrate/appium.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ For a migration that spans several sessions, the [`migrate-to-e2e` skill](/codin
| `appium:deviceName`, `appium:udid` | `mobile({ device: 'iPhone 17' })`: a name, a simulator UDID, or an `emulator-5554` serial. A phone goes by its name |
| `appium:app` | `app: { appPath }`. Install the build yourself, see [Point at your app](/mobile#point-at-your-app) |
| `appium:bundleId`, `appium:appPackage` | `app: { bundleId }`, the app `app.open()` launches |
| `appium:processArguments`, `appium:optionalIntentArguments` | `app.launchArguments`, a list of strings |
| `appium:processArguments`, `appium:optionalIntentArguments` | `app.launchArguments`, a list of strings or an object of argument name to value |
| `appium:permissions` | `app.permissions: { camera: 'grant' }`. Each [`DevicePermission`](/reference/mobile#device-fixture) name takes `grant`, `deny`, or `reset` |
| `appium:noReset` | `true` is the default, so nothing clears the app's data. For `false`, call `app.clearState()` at the start of the test |
| `appium:fullReset` | `device.installApp(path, { reinstall: true })` |
Expand Down Expand Up @@ -300,7 +300,7 @@ is not a step, so it skips the report and secret redaction.
| `bstack:options.local`, `lt:options.tunnel` | Point the app at a backend the hosted device can reach |
| `appium:appActivity`, `appWaitActivity`, `startActivity()` | `device.openLink(url)`, or `client.apps.open` through [`unstable_raw`](/reference/mobile#unstable_raw) |
| `appium:processArguments.env` | Pass a launch argument and read it in the app |
| `appium:language`, `appium:locale` on a local device | On iOS, `app.launchArguments: ['-AppleLanguages', '(fr)', '-AppleLocale', 'fr_FR']`, see [Run the app in another language](/mobile#run-the-app-in-another-language). On Android, set the device language before the run |
| `appium:language`, `appium:locale` on a local device | On iOS, `app.launchArguments: { AppleLanguages: ['fr'], AppleLocale: 'fr_FR' }`, see [Run the app in another language](/mobile#run-the-app-in-another-language). On Android, set the device language before the run |
| `appium:disableWindowAnimation`, `reduceMotion` | On Android, `client.settings.update` through [`unstable_raw`](/reference/mobile#unstable_raw) |

</Accordion>
Expand Down
17 changes: 12 additions & 5 deletions docs/migrate/detox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ For a migration that spans several sessions, the [`migrate-to-e2e` skill](/codin
| `devices.<name>.device.type` | `mobile({ device: 'iPhone 17' })` |
| `configurations` | `targets`, one engine per platform |
| Jest `maxWorkers` | `workers`, one per device |
| `apps.<name>.launchArgs` | `app.launchArguments` on the target, a list of strings for each platform |
| `apps.<name>.launchArgs` | `app.launchArguments` on the target. Use an object with the same keys, or a list of strings for each platform. On Android, each key is a separate typed extra on the launch intent. Detox puts all keys as strings in one `launchArgs` bundle extra, so change code that reads `getIntent().getBundleExtra("launchArgs")`. On iOS, each key is a `UserDefaults` argument: `false` becomes `NO`, and a string such as `a b` or `-1` gets quotes. If the app reads `ProcessInfo.processInfo.arguments`, use the list format. Nested objects are not supported |
| `launchApp({ permissions })` | `app.permissions` on the target: `grant`, `deny`, `reset` for `YES`, `NO`, `unset`. More names are [planned](#planned) |

```ts title="e2e.config.ts"
Expand All @@ -55,12 +55,20 @@ export default {
{
name: 'ios',
engine: mobile({ platform: 'ios' }),
app: { bundleId: 'com.example.app', appPath: 'ios/build/MyApp.app' },
app: {
bundleId: 'com.example.app',
appPath: 'ios/build/MyApp.app',
launchArguments: ['-mockServer', 'http://localhost:9001'],
},
},
{
name: 'android',
engine: mobile({ platform: 'android' }),
app: { bundleId: 'com.example.app', appPath: 'android/app/build/outputs/apk/debug/app-debug.apk' },
app: {
bundleId: 'com.example.app',
appPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
launchArguments: ['--es', 'mockServer', 'http://localhost:9001'],
},
},
],
workers: 1,
Expand Down Expand Up @@ -167,10 +175,9 @@ on purpose.
| `.toHaveValue(v)` outside a form control | `expect(device.locator('id=x value="v"')).toBeVisible()` |
| `permissions` for `health`, `homekit`, `speech`, `faceid`, `userTracking`; values `always`, `inuse`, `limited` | Tap the prompt's button, or `device.alert('accept')` |
| `device.sendUserNotification()`, `.pinch()` | `client.apps.push()`, `client.interactions.pinch()` on [`unstable_raw`](/reference/mobile#unstable_raw) |
| `launchApp({ languageAndLocale })` | On iOS, `app.launchArguments: ['-AppleLanguages', '(fr)', '-AppleLocale', 'fr_FR']`, see [Run the app in another language](/mobile#run-the-app-in-another-language) |
| `launchApp({ languageAndLocale })` | On iOS, `app.launchArguments: { AppleLanguages: ['fr'], AppleLocale: 'fr_FR' }`, see [Run the app in another language](/mobile#run-the-app-in-another-language) |
| Jest `globalSetup`, `globalTeardown` | Start dependencies before the run |
| `device.reverseTcpPort()` | Run `adb reverse` in a CI step |
| `launchArgs` as one key-value map | `['-key', 'value']` on iOS, `['--es', 'key', 'value']` on Android |
| `.getAttributes()` | `.textContent()`, `.inputValue()`, `.isEnabled()`, `.isVisible()`, `.isChecked()`, `.boundingBox()` |
| `device.setStatusBar()` | `xcrun simctl status_bar`. `toHaveScreenshot` holds the status bar fixed |

Expand Down
Loading