> ## Documentation Index
> Fetch the complete documentation index at: https://e2e.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# From Maestro

> Move Maestro flows to TypeScript with locators, assertions, and agent goals.

export const migrationPrompt = `Migrate this project's Maestro flows to e2e, one flow at a time. Docs: \`https://e2e.com/docs/migrate/maestro.md\` and \`https://e2e.com/docs/mobile.md\`

1. Read the migration guide above. It maps the Maestro config options and commands e2e has, and lists what e2e does not have yet with what to use today. The mobile guide covers devices and app builds.
2. e2e tests are TypeScript. If the project has no \`package.json\`, as in a native iOS or Android project, create the test project in an \`e2e/\` folder beside the app.
3. If the test project has no e2e config (\`e2e.config.ts\`, \`.mts\`, \`.js\`, or \`.mjs\`), run \`npx e2e init --yes --engine mobile\` (or the pnpm or bun equivalent) there. It writes a mobile config with one target for this machine's platform and an example test against the Settings app, and installs nothing yet. Rewrite \`tests/example.e2e.ts\` for your app or delete it.
4. Read the e2e skill (\`npx e2e guide\` prints it, \`npx e2e guide <topic>\` prints a topic) and follow it for every step below.
5. If you ran init, ask me which model to use for agent steps: a ChatGPT, GitHub Copilot, OpenCode Console, or SuperGrok subscription, an API key, or a local model. Configure it with its provider package. If it needs a sign-in, give me the \`npx e2e login\` command and wait until I confirm.
6. Port the flows' \`appId\` and \`.maestro/config.yaml\` into the e2e config: one target per platform with \`mobile({ platform })\`, \`app: { bundleId }\` on each target, and tags as \`{ tags }\` on tests. Move passwords and tokens from \`env\` into \`credentials\` or \`secrets\`.
7. Install dependencies, then run \`npx e2e doctor\` (e2e 0.23.0 or newer) and fix what it reports.
8. List the flows and ask me which one to move first. Suggest one whose \`optional\` steps and \`runFlow: { when }\` branches often need updating.
9. Rewrite that flow as a \`.e2e.ts\` test under \`tests/\` (e2e runs \`tests/**/*.e2e.ts\` by default), with one awaited call per command. Start it with \`app.open()\`, since nothing launches on its own. Follow the guide's "Rewrite selectors" and "What differs on purpose" sections: e2e matches the whole string, fails on several matches, and grants no permission the config does not name. Check "What e2e doesn't have yet" before you port a flow: for a command listed there, use its "Use today" workaround, or leave that flow in Maestro and tell me why.
10. Keep the launch and the final assertions deterministic, with \`app.open()\` and locator assertions. Where a run of scripted taps breaks often, propose an \`agent.act\` goal for it instead.
11. Build and install the app, run the new file with \`npx e2e run <file>\` on each platform target, and fix it until it passes. Keep the Maestro flow until I confirm it can go.
12. Summarize which flows moved, which stayed in Maestro, and why.`;

e2e replaces Maestro's YAML flows with TypeScript tests. Each command becomes
an awaited call, usually on a locator, or one agent goal covers several. Both runners can
use the same simulator or emulator while you move one flow at a time.

<SetupPrompt>

<Prompt description={migrationPrompt} children={migrationPrompt} actions={["copy", "cursor"]} />

</SetupPrompt>

For a migration that spans several sessions, the [`migrate-to-e2e` skill](https://e2e.com/docs/coding-agents#migrate-an-existing-suite) records what moved in a progress file and keeps the old suite running until you retire each test.

## Port the config

<Note>Set up a target with the [mobile guide](https://e2e.com/docs/mobile) and a model with the [quickstart](https://e2e.com/docs/quickstart).</Note>

| Maestro | e2e |
| --- | --- |
| `appId` at the top of every flow | `app: { bundleId: 'com.example.app' }` on the target, the app `app.open()` launches |
| a different `appId` per flow, or a second one mid-flow | `device.openApp(id)` in the test, or one config per app |
| `--platform`, `--device` | `mobile({ platform: 'ios', device: 'iPhone 17' })`, one target per platform; a `device` list is a pool. For one run, `e2e run --target ios --device 'iPhone 17'` |
| `.maestro/config.yaml` `flows`, `'!helper.yaml'` | `tests: ['tests/**/*.e2e.ts', '!tests/helpers/**']` |
| `tags`, `--include-tags`, `--exclude-tags` | `{ tags: [...] }` on a test or group; `--tag`, `--exclude-tag` on the CLI |
| `env` and `${VAR}` | module constants, and `params` in a goal: `agent.act('sign in as {email}', { params: { email } })` |
| `MAESTRO_*` variables | `process.env` in the config; passwords and tokens go under `credentials` or `secrets`, see [Authentication](https://e2e.com/docs/authentication) |
| `--format junit` | `--reporter list,junit` writes `.e2e/junit.xml` |
| `--format html` | `htmlReporter()` from `@e2e-dev/html-reporter` writes `.e2e/report.html` |
| `--shards`, `--shard-split` | `device: [...]` plus `workers` on one machine; `--shard <index/total>` across machines, see [Sharding](https://e2e.com/docs/ci#sharding) |
| `maestro record` | `npx e2e run --video`, one MP4 of the device per attempt, or a hosted provider's own recording |
| `maestro test -c` | `npx e2e run --watch` |
| `maestro hierarchy` | `await screen.debug()` in a test prints the screen's tree; `screen.tree()` returns it |

## Rewrite one flow

Start with a flow whose `optional` steps and `runFlow: { when }` branches
often need updating.

```yaml title="Maestro"
appId: com.example.app
---
- launchApp:
    clearState: true
- tapOn: "Get started"
- tapOn:
    id: "email"
- inputText: "ada@example.test"
- tapOn: "Continue"
- assertVisible: "Check your inbox"
- scrollUntilVisible:
    element: "Resend"
- assertVisible:
    id: "resend"
```

```ts title="e2e"

test('asks for the email', async ({ app, agent, screen }) => {
  await app.clearState();
  await agent.act('get started with the email {email}', { params: { email: 'ada@example.test' } });
  await expect(screen.getByText('Check your inbox')).toBeVisible();
  await screen.scrollUntilVisible(screen.getByTestId('resend'));
  await expect(screen.getByTestId('resend')).toBeVisible();
});
```

## Map each command

Calls on `device` run only on a device, so a test that uses it declares
`requires: ['device']` and other targets skip it. For signatures, see
[screen](https://e2e.com/docs/reference/screen), [expect](https://e2e.com/docs/reference/expect),
[test](https://e2e.com/docs/reference/test), and the [mobile engine](https://e2e.com/docs/reference/mobile).

<AccordionGroup>
<Accordion title="App and device">

| Maestro | e2e |
| --- | --- |
| `launchApp` | `app.open()`, a fresh launch of the target's app; nothing launches on its own |
| `clearState`, `launchApp: { clearState: true }` | `app.clearState()` |
| `launchApp: { stopApp: false }` | `device.openApp(id)` without `relaunch` |
| `launchApp: { arguments }` | `app.launchArguments` on the target, a list of strings, not a map; `device.openApp(app, { relaunch: true, launchArguments })` for one launch |
| `launchApp: { permissions }`, `setPermissions` | `app.permissions` on the target, or `device.openApp(app, { relaunch: true, permissions })` for one launch; `grant`, `deny`, `reset` for `allow`, `deny`, `unset`. `device.setPermission(name, state)` before `app.open()` |
| `stopApp`, `killApp` | `device.closeApp()`, a force stop; `app.restart()` to stop the app and launch it again |
| `clearKeychain`, `openLink`, `setLocation`, `setAirplaneMode`, `setOrientation`, `setClipboard` | the same on `device`, such as `device.openLink(url)`. `clearKeychain` is iOS simulator only, `setAirplaneMode(true)` Android 11 or newer. For `travel`, loop `device.setLocation` |
| `back`, `pressKey: Home`, `hideKeyboard`, `setDarkMode` | `app.back()`, `device.home()`, `device.dismissKeyboard()`, `device.setAppearance('dark')` |
| `pressKey: Remote Dpad Up`, `Down`, `Left`, `Right`, `Remote Dpad Center` | `device.pressRemote('up')`, `'down'`, `'left'`, `'right'`, `'select'` |
| `pressKey: Remote Media Play Pause`, `Remote Media Stop`, `Remote Media Next`, `Remote Media Previous`, `Remote Media Rewind`, `Remote Media Fast Forward`, `Remote Menu` | `device.pressRemote('play-pause')`, `'stop'`, `'next'`, `'previous'`, `'rewind'`, `'fast-forward'`, `'menu'`; the [remote keys](https://e2e.com/docs/reference/engine#keys) list the rest |

</Accordion>
<Accordion title="Taps, input, and swipes">

| Maestro | e2e |
| --- | --- |
| `tapOn: "Text"`, `tapOn: { id: x }` | `screen.getByText('Text').tap()`, `screen.getByTestId('x').tap()`, see [Rewrite selectors](#rewrite-selectors) |
| `index: 2`, `containsDescendants`, `childOf` | `.nth(2)`, `.filter({ has: other })`, `parent.getByText('Text')` |
| platform-specific selectors | `device.locator('role=text label="..."')`, agent-device's selector terms |
| `tapOn: { point: "x,y" }`, `point: "50%,50%"` | `screen.tapAt({ x, y })`, `screen.tapAt({ x: '50%', y: '50%' })`; inside a node, `.tap({ position: { x, y } })` |
| `doubleTapOn`, `longPressOn` | `.doubleTap()`, `.longPress({ duration })` |
| `inputText`, `eraseText`, `pressKey: Enter` after a `tapOn` | `.fill('text')`, `.clear()`, `.press('Enter')` on the field's locator |
| `inputRandomEmail`, `inputRandomText`, `faker` | `unique()` around a value in `act` params, so the cache still replays; any npm faker for the rest |
| `copyTextFrom`, `pasteText` | `await locator.textContent()`, then `.fill(text)` |
| `swipe: { direction: UP }`, `scroll` | `screen.swipe({ direction: 'down' })`; Maestro names the finger's direction, e2e the content's |
| `swipe: { start, end }`, `scrollUntilVisible` | `screen.swipe({ from, to })` in pixels or percentages, `screen.scrollUntilVisible(locator, { direction })` |

</Accordion>
<Accordion title="Assertions and flows">

| Maestro | e2e |
| --- | --- |
| `assertVisible`, `assertNotVisible`, `extendedWaitUntil` | `await expect(locator).toBeVisible({ timeout })`, `.toBeHidden()` |
| `assertVisible: { enabled, checked, selected, focused }` | `.toBeVisible()`, then `.toBeEnabled()`, `.toBeChecked()`, `.toBeSelected()`, or `.toBeFocused()` |
| `assertTrue: ${...}` | `expect(value).toBe(true)`, or `expect.poll` for a value that is still changing |
| `assertScreenshot: { path, thresholdPercentage }` | `await expect(screen).toHaveScreenshot(name, { maxDiffPixelRatio })`, see [Visual comparison](https://e2e.com/docs/visual-testing) |
| `takeScreenshot`, `startRecording`, `stopRecording` | `app.screenshot('label')`, [`app.startRecording()`, `app.stopRecording()`](https://e2e.com/docs/reference/app#startrecording) |
| `assertWithAI`, `assertNoDefectsWithAI`, `extractTextWithAI` | `agent.assert('...', { vision: true })`, `agent.extract('...', { schema })` |
| `runFlow: file.yaml`, `onFlowStart`, `onFlowComplete` | a function or a `test.extend` fixture; `beforeEach`, `afterEach` |
| `runFlow: { when: { visible } }` | `if (await locator.isVisible()) { ... }`, see [Rewrite selectors](#rewrite-selectors) |
| `repeat`, `runScript`, `evalScript`, `${output.x}`, `http.get` | TypeScript in the test: loops, variables, and Node `fetch`, see [API](https://e2e.com/docs/api-testing) |

</Accordion>
</AccordionGroup>

## Rewrite selectors

- Maestro reads text and id as case-insensitive regular expressions.
  `getByText` and `getByTestId` match the whole string, case included. Write
  `getByText(/^mute account$/i)`, or `{ exact: false }` for a substring of text.
- Maestro taps the first of several matches. e2e fails with
  `LOCATOR_AMBIGUOUS`, so add `.first()` when the first match is what you mean.
- `isVisible()` replaces `optional` and `runFlow: { when }`. It reads the
  screen one time and doesn't wait. It fails on several matches, so add
  `{ visible: true }` or `.first()` when a hidden twin may exist.
- `below`, `above`, `leftOf`, and `rightOf` have no port, see
  [Not yet](#not-yet). `filter({ has })` and chaining match nothing on a
  plain React Native `View` on iOS, see [Known device limitations](https://e2e.com/docs/mobile#known-device-limitations).

## What e2e doesn't have yet

Planned is on the roadmap, and Not yet has no date. Not planned is left out
on purpose.

### Planned

| Maestro | Use today |
| --- | --- |
| `permissions: { all }`, the grant-all default, names such as `bluetooth` and `storage` | Name each permission in `app.permissions`, or accept the prompt with `device.alert('accept')` |
| `inputText` and `pressKey: Enter` with no field, `eraseText: N`, `pressKey: backspace`, `tab` | `fill` or `press` on the field's locator; `fill` a shortened `inputValue()` to erase; tap the next field for Tab |
| `addMedia` | On an iOS simulator, `xcrun simctl addmedia` before `app.open()`; Android is unchecked. See "Photos for a picker test" under [The device fixture](https://e2e.com/docs/mobile#the-device-fixture) |
| `label` on a command | `-`. The call names each step |
| `scrollUntilVisible: { centerElement, visibilityPercentage }` | No exact match. After it resolves, read `boundingBox()`, then `screen.swipe({ direction, momentum: 'slow' })` if the node is off center |
| Device logs and crash reports beside a failure | `adb logcat` or `xcrun simctl spawn <udid> log stream`, collected in a fixture |
| `maestro hierarchy` as a terminal command | A one-line test that calls `screen.debug()` |
| `--device-locale` | `app.launchArguments: ['-AppleLanguages', '(de)', '-AppleLocale', 'de_DE']` on iOS, see [Run the app in another language](https://e2e.com/docs/mobile#run-the-app-in-another-language); on Android, set the device language before the run |
| Maestro Cloud | Your [CI](https://e2e.com/docs/ci) with a [hosted device provider](https://e2e.com/docs/mobile#hosted-devices) |
| `pressKey: lock`, `power`, `volume up`, `volume down` | `client.command.hardwareButton` on [`unstable_raw`](https://e2e.com/docs/reference/mobile#unstable_raw): power and volume on Android, volume on a physical iPhone |
| JUnit `properties`, a JUnit path with `--output` | Ids in tags or the title; copy `.e2e/junit.xml` after the run |

### Not yet

| Maestro | Use today |
| --- | --- |
| `optional: true` | `if (await locator.isVisible())` or try/catch; the report shows no warning |
| `executionOrder` | One `describe(..., { serial: true })` that calls each flow as a function |
| `retry: { maxRetries, commands }` | A `for` loop with try/catch; `expect.poll` for a value, `{ retries }` for the whole test |
| Android process death with `killApp` | `device.home()`, then `adb shell am kill <package>`, then `device.openApp(id)` |
| `assertDarkMode`, `assertLightMode` | Assert on a themed control, or `toHaveScreenshot` |
| `Remote System Navigation Up`, `Down`, `Remote Button A`, `B` | `-` |

### Not planned

| Maestro | Use instead |
| --- | --- |
| Text and id as regex, first match wins | A `RegExp` and `.first()`, see [Rewrite selectors](#rewrite-selectors) |
| `retryTapIfNoChange` | Assert the result, then tap again in the test. A blind second tap can fire a control twice |
| `waitToSettleTimeoutMs` | An assertion with its own `timeout` after the action; that assertion is the wait |
| `toggleAirplaneMode`, `toggleDarkMode` | Set the state you want: `device.setAirplaneMode(true)`, `device.setAppearance('dark')` |
| Maestro Studio | A coding agent over [`npx e2e mcp`](https://e2e.com/docs/mcp-server), or `screen.debug()` with `npx e2e run --watch` or `--step` |
| `waitForAnimationToEnd` | `await expect(locator).toBeVisible()` on what the animation ends with |
| `below`, `above`, `leftOf`, `rightOf` | `getByLabel`, a test id, `filter({ has })` on a shared container, or an `agent.act` goal |

## What differs on purpose

- Maestro grants every permission when it launches the app. e2e grants none
  unless you name it, so a ported flow meets system prompts Maestro never
  showed. Name each one in [`app.permissions`](https://e2e.com/docs/mobile#launch-arguments-and-permissions),
  with `grant`, `deny`, and `reset` for Maestro's `allow`, `deny`, and `unset`.
- Calls through [`device.unstable_raw`](https://e2e.com/docs/reference/mobile#unstable_raw)
  aren't steps. The report, the trace, the agent cache, and redaction skip them.
- A device has no `test.setup` or `{ session }`, see
  [what differs from the web](https://e2e.com/docs/mobile#what-differs-from-the-web).

## Next

<CardGroup cols={2}>
  <Card title="Mobile" icon="mobile-screen" href="/mobile">
    Configure your app and devices.
  </Card>
  <Card title="Core concepts" icon="pen-to-square" href="/core-concepts">
    Goals, assertions, and locators instead of scripted selectors.
  </Card>
</CardGroup>
