> ## 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 Detox

> Use your existing app build and testIDs with screen, expect, and agent goals.

export const migrationPrompt = `Migrate this project's Detox tests to e2e, one spec at a time. Docs: \`https://e2e.com/docs/migrate/detox.md\` and \`https://e2e.com/docs/mobile.md\`

1. Read the migration guide above. It maps \`.detoxrc.js\` and the Detox API to e2e, and lists what e2e doesn't have yet. The mobile guide covers devices and app builds.
2. If the 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). 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.
3. Read the e2e skill (\`npx e2e guide\` prints it, \`npx e2e guide <topic>\` prints a topic) and follow it for every step below.
4. 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.
5. Port \`.detoxrc.js\` into the e2e config: one target per platform with \`mobile({ platform })\`, the app's \`bundleId\` and \`appPath\` on the target, and the device type as \`mobile({ device })\`. e2e uses the normal debug or release build, with no Detox framework.
6. Install dependencies, then run \`npx e2e doctor\` (e2e 0.23.0 or newer) and fix what it reports.
7. List the Detox specs and ask me which one to move first. Suggest a flow that needs frequent maintenance.
8. Check each Detox call in that spec against "What e2e doesn't have yet". Use the "Use today" or "Use instead" entry, or leave the spec in Detox and say why. Then rewrite the spec as a \`.e2e.ts\` file under \`tests/\` (e2e runs \`tests/**/*.e2e.ts\` by default), not in the Detox folder, with the guide's mapping tables. Start it with \`app.open()\`, since nothing launches on its own. Narrow queries that match several nodes.
9. Keep the launch and the final assertions deterministic, with \`app.open()\` and locator assertions. Where a run of scripted interactions breaks often, propose an \`agent.act\` goal for it instead.
10. 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 Detox spec until I confirm it can go.
11. Summarize which tests moved, which stayed in Detox, and why.`;

e2e tests a React Native app on a simulator or emulator with your normal
debug or release build, with no Detox framework in the app. Your `testID`
props work with `getByTestId` on both platforms.

<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). Both runners can use the same simulator while you move one spec at a time.</Note>

| Detox (`.detoxrc.js`) | e2e |
| --- | --- |
| `apps.<name>.binaryPath`, `bundleId` | `app: { appPath, bundleId }` on the target |
| `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 |
| `launchApp({ permissions })` | `app.permissions` on the target: `grant`, `deny`, `reset` for `YES`, `NO`, `unset`. More names are [planned](#planned) |

```ts title="e2e.config.ts"

export default {
  targets: [
    {
      name: 'ios',
      engine: mobile({ platform: 'ios' }),
      app: { bundleId: 'com.example.app', appPath: 'ios/build/MyApp.app' },
    },
    {
      name: 'android',
      engine: mobile({ platform: 'android' }),
      app: { bundleId: 'com.example.app', appPath: 'android/app/build/outputs/apk/debug/app-debug.apk' },
    },
  ],
  workers: 1,
} satisfies E2EConfig;
```

## Rewrite one spec

Nothing launches on its own, so the e2e test starts with `app.open()`. The
password comes from [configured credentials](https://e2e.com/docs/authentication).

```js title="Detox"
describe('login', () => {
  beforeAll(async () => { await device.launchApp({ newInstance: true }); });

  it('shows the home screen', async () => {
    await element(by.id('email')).typeText('ada@example.test');
    await element(by.id('password')).typeText('hunter2');
    await element(by.text('Sign in')).tap();
    await waitFor(element(by.id('home'))).toBeVisible().withTimeout(10000);
    await expect(element(by.text('Welcome, Ada'))).toBeVisible();
  });
});
```

```ts title="e2e"

test('shows the home screen', async ({ agent, app, screen }) => {
  await app.open();
  const ada = credentials.user('ada');
  await agent.act('sign in as {username}', { params: { username: ada.username, password: ada.password } });
  await expect(screen.getByTestId('home')).toBeVisible({ timeout: 10_000 });
  await expect(screen.getByText('Welcome, Ada')).toBeVisible();
});
```

## Map each Detox call

### Matchers and actions

| Detox | e2e |
| --- | --- |
| `by.id('x')`, `by.text('t')`, `by.label('l')` | `screen.getByTestId('x')`, `screen.getByText('t')`, `screen.getByLabel('l')` |
| `by.id('x').withAncestor(by.id('row'))` | `screen.getByTestId('row').getByTestId('x')` |
| `.atIndex(n)` | `.nth(n)` |
| `.tap()`, `.tap({ x, y })`, `.longPress()`, `.multiTap(2)` | `.tap()`, `.tap({ position: { x, y } })`, `.longPress()`, `.doubleTap()` |
| `.typeText(t)` | `.pressSequentially(t)` |
| `.replaceText(t)`, `.clearText()`, `.tapReturnKey()` | `.fill(t)`, `.clear()`, `.press('Enter')` |
| `.swipe('up', 'fast')` | `.swipe({ direction: 'down', momentum: 'fast' })`. Detox names the finger's direction, e2e the content's |
| `list.scroll(200, 'down')` | `list.swipe({ direction: 'down' })`, with no offset |
| `waitFor(el).toBeVisible().whileElement(list).scroll(...)` | `list.scrollUntilVisible(el)`, with `{ direction: 'up' }` when Detox scrolls up |

### Expectations

| Detox | e2e |
| --- | --- |
| `waitFor(el).toBeVisible().withTimeout(ms)` | `await expect(el).toBeVisible({ timeout: ms })` |
| `.toBeVisible()`, `.toHaveText(t)` | The same |
| `.not.toBeVisible()` | `.toBeHidden()` |
| `.toExist()`, `.not.toExist()` | `.toBeAttached()`, `.toBeAttached({ attached: false })` |
| `.toHaveToggleValue(true)` | `.toBeChecked()` |
| `.toHaveLabel(l)` | `.toHaveAccessibleName(l)` |
| `.toHaveValue(v)` | `.toHaveValue(v)`, on a form control only |

### Device

| Detox | e2e |
| --- | --- |
| `device.launchApp({ newInstance: true })` | `app.restart()` |
| `device.launchApp()` in `beforeAll` | `app.open()` in `beforeAll`, which gets `device`, `app`, and `screen` |
| `device.launchApp({ newInstance: false })` | `device.openApp(id)` without `relaunch` |
| `device.launchApp({ launchArgs, permissions })` | `device.openApp(id, { relaunch: true, launchArguments, permissions })` |
| `device.resetAppState()` | `app.clearState()` |
| `device.launchApp({ delete: true })` | `device.installApp(path, { reinstall: true })`, then `app.open()` |
| `device.uninstallApp()` | `device.uninstallApp(id)`; without an id, the pinned app |
| `device.launchApp({ url })`, `device.openURL({ url })` | `device.openLink(url)` |
| `device.terminateApp()`, `sendToHome()`, `pressBack()` | `device.closeApp()`, `home()`, `back()` |
| `device.setLocation(lat, lon)`, `setOrientation('landscape')` | `device.setLocation({ latitude, longitude })`, `setOrientation('landscape-left')` |
| `device.setBiometricEnrollment(true)` | `device.enrollBiometrics('faceid', true)` |
| `device.matchFace()`, `unmatchFace()`, `matchFinger()`, `unmatchFinger()` | `device.setBiometrics('faceid' \| 'touchid', 'match' \| 'nonmatch')` |
| `device.takeScreenshot()` | `app.screenshot('label')`, or [`toHaveScreenshot`](https://e2e.com/docs/visual-testing) to compare |
| `device.getPlatform()` | The `platform` fixture |
| `:ios:` / `:android:` in a test name | `{ platforms: ['ios'] }` on the test |

## 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

| Detox | Use today |
| --- | --- |
| `artifacts.plugins.log`, `--record-logs` | `adb logcat` or `xcrun simctl spawn booted log stream` in a CI step |
| `by.id('x').and(by.text('y'))` | `.filter({ hasText })`, or `device.locator('id=x label="y"')` |
| `system.element(by.system.label('Allow'))` | `device.alert('accept' \| 'dismiss')`, or `app.permissions` so no prompt shows |
| `.longPressAndDrag()`, `.swipe()` offset, `.multiTap(3)` | `.dragTo(target)`, `screen.swipe({ from, to })`, repeated `.tap()` |
| `.scrollTo('bottom')` | `list.scrollUntilVisible(lastRow)`, or the first row with `{ direction: 'up' }` |
| `.tapBackspaceKey()` | `.fill(t)` with the shorter text |
| `.setDatePickerDate()`, `.setColumnToValue()`, `.adjustSliderToPosition()` | An `agent.act` goal, or `screen.swipe({ from, to })` on a slider |
| `.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`](https://e2e.com/docs/reference/mobile#unstable_raw) |
| `launchApp({ languageAndLocale })` | On iOS, `app.launchArguments: ['-AppleLanguages', '(fr)', '-AppleLocale', 'fr_FR']`, see [Run the app in another language](https://e2e.com/docs/mobile#run-the-app-in-another-language) |
| Jest `globalSetup`, `globalTeardown` | Start dependencies before the run |
| `device.reverseTcpPort()` | Run `adb reverse` in a CI step |
| `device.shake()` | - |
| `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 |

### Not yet

| Detox | Use today |
| --- | --- |
| `.toBeVisible(50)`, and the 75% default | `.toBeVisible()` checks the platform's flag, not the area. Compare `.boundingBox()` |
| `web.element(by.web.cssSelector('x'))` | The WebView's accessibility text and labels, or an `agent.act` goal |
| `device.resetContentAndSettings()` | `app.clearState()`, plus `device.clearKeychain()` on iOS |
| `device: { type, os }`, `headless`, `bootArgs` | Create and boot the device in a CI step |

### Not planned

| Detox | Use instead |
| --- | --- |
| `device.reloadReactNative()` | `app.restart()`. A reload needs the Detox framework in the app |
| `device.disableSynchronization()`, `enableSynchronization()` | Delete the calls. There is no synchronization to switch off |
| `device.setURLBlacklist()` | Delete the call. Network activity never blocks an action |
| Install at init, `behavior.init.reinstallApp`, `--reuse` | `device.installApp()` in a worker fixture with `auto: true` |
| `apps.<name>.build`, `detox build` | Your normal build, before `e2e run` |
| `.scroll()` by an exact offset | `screen.swipe({ from, to })` |
| `by.type('RCTImageView')` | `device.locator('role=image')`, or a `testID` |
| Jest reporters, Allure | The `junit` reporter, or a custom reporter |

## What differs on purpose

- e2e doesn't wait for the app to be idle. Actions wait and assertions retry.
  For a control that is still arriving, raise [`transition`](https://e2e.com/docs/reference/mobile#transition);
  for agent actions, [`settle`](https://e2e.com/docs/reference/mobile#settle).
- The engine installs nothing on its own. Call `device.installApp()`.
- [Locators](https://e2e.com/docs/reference/screen) are strict. An action on several matches fails
  with `LOCATOR_AMBIGUOUS`. Narrow with `.filter()`, `.first()`, or `.nth()`.
- 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="Mobile engine reference" icon="book" href="/reference/mobile">
    Every option, the `device` fixture, and the tool pack.
  </Card>
</CardGroup>
