### Check agent-device setup Source: https://docs.expo.dev/guides/using-e2e Run this command to verify your Android Emulator or iOS Simulator setup. It is part of the prerequisites for using e2e. ```bash npx agent-device doctor ``` -------------------------------- ### Write tests with exact steps in tests/home.e2e.ts Source: https://docs.expo.dev/guides/using-e2e Create tests/home.e2e.ts. Each test starts with app.open(), which launches the app set in app.bundleId. Without it, a test starts on the screen the previous test left open. ```ts import { test } from '@e2e-dev/mobile'; import { expect } from 'e2e'; test('home screen shows the welcome title', async ({ app, screen }) => { await app.open(); await expect(screen.getByText('Welcome to Expo')).toBeVisible(); }); test('explore tab expands file-based routing', async ({ app, screen }) => { await app.open(); await screen.getByText('Explore').tap(); await screen.getByText('File-based routing', { exact: false }).tap(); await expect(screen.getByText('This app has two screens', { exact: false })).toBeVisible(); }); ``` -------------------------------- ### Initialize e2e in your project Source: https://docs.expo.dev/guides/using-e2e Run the setup command to add e2e to your project. Then answer prompts to select the engine, model gateway, and confirm file changes. ```sh npx e2e init ``` -------------------------------- ### Build and install release builds for Android and iOS Source: https://docs.expo.dev/guides/using-e2e Create a release build and install it on an emulator or simulator. A release build includes the JavaScript bundle, so tests do not need a running development server. ```sh # Build and install on an Android Emulator npx expo run:android --variant release # Build and install on an iOS Simulator npx expo run:ios --configuration Release ``` -------------------------------- ### Sign in to e2e with npx e2e login Source: https://docs.expo.dev/guides/using-e2e Sign in to e2e to use a subscription provider. Run this before adding an agent step if you selected a subscription during setup. ```sh npx e2e login ``` -------------------------------- ### Run workflow with eas workflow:run Source: https://docs.expo.dev/guides/using-e2e Starts the workflow by running the command 'eas workflow:run .eas/workflows/e2e-tests.yml'. ```sh eas workflow:run .eas/workflows/e2e-tests.yml ``` -------------------------------- ### Install @e2e-dev/eas with npm, yarn, pnpm, or bun Source: https://docs.expo.dev/guides/using-e2e Install the EAS Simulator integration as a development dependency using your preferred package manager. ```sh # npm npm install --save-dev @e2e-dev/eas # yarn yarn add --dev @e2e-dev/eas # pnpm pnpm add --save-dev @e2e-dev/eas # bun bun add --dev @e2e-dev/eas ``` -------------------------------- ### Create EAS Workflow e2e-tests.yml Source: https://docs.expo.dev/guides/using-e2e Defines a workflow that builds an iOS Simulator app, boots a simulator, installs the app, runs e2e tests, and uploads artifacts. It uses the 'e2e-ios-simulator' profile and the 'e2e.ci.config.ts' configuration. ```yaml name: e2e tests on: workflow_dispatch: {} jobs: build_ios: name: Build iOS Simulator app type: build params: platform: ios profile: e2e-ios-simulator e2e_ios: name: Run e2e tests on iOS needs: [build_ios] runs_on: macos-medium environment: preview steps: - uses: eas/checkout - uses: eas/install_node_modules - uses: eas/download_build id: download_build with: build_id: ${{ needs.build_ios.outputs.build_id }} extensions: [app] - name: Boot a simulator and install the app run: | UDID=$(xcrun simctl list devices available --json | node -e "const d=JSON.parse(require('fs').readFileSync(0,'utf8')).devices; const all=Object.values(d).flat(); console.log(all.find(x=>x.name.startsWith('iPhone')).udid)") xcrun simctl boot "$UDID" xcrun simctl bootstatus "$UDID" -b xcrun simctl install "$UDID" "${{ steps.download_build.outputs.artifact_path }}" - name: Run e2e run: npx e2e run --config e2e.ci.config.ts - uses: eas/upload_artifact if: ${{ always() }} with: type: other name: e2e-report path: | .e2e/report.json .e2e/artifacts/**/* ``` -------------------------------- ### Run e2e tests on EAS Simulator Source: https://docs.expo.dev/guides/using-e2e Run the tests with the EAS Simulator config, setting `EXPO_TOKEN` and `IOS_SIMULATOR_BUILD_ID` environment variables. The session is ready after EAS boots the simulator and installs the build. ```sh EXPO_TOKEN= IOS_SIMULATOR_BUILD_ID= npx e2e run --config e2e.eas.config.ts ``` -------------------------------- ### Link project to EAS and check simulator availability Source: https://docs.expo.dev/guides/using-e2e Run `eas init` to set `extra.eas.projectId` in your app config, and `eas simulator:availability --json` to verify your account can use EAS Simulator. ```sh eas init eas simulator:availability --json ``` -------------------------------- ### Create an agent test file (tests/agent.e2e.ts) Source: https://docs.expo.dev/guides/using-e2e Defines an e2e test with one agent.act() call and an exact assertion. The agent opens the app, performs the action, and the test verifies the expected text is visible. ```ts import { test } from '@e2e-dev/mobile'; import { expect } from 'e2e'; test('agent expands file-based routing on the explore tab', async ({ agent, app, screen }) => { await app.open(); await agent.act('open the Explore tab, then expand the File-based routing section'); await expect(screen.getByText('This app has two screens', { exact: false })).toBeVisible(); }); ``` -------------------------------- ### Record a video with npx e2e run --target ios --video Source: https://docs.expo.dev/guides/using-e2e Adds --video to record a video of each test run. Use this to debug test failures visually. ```sh npx e2e run --target ios --video ``` -------------------------------- ### Run e2e tests Source: https://docs.expo.dev/guides/using-e2e Run the tests on both platforms. e2e boots the configured emulator or simulator if it is not running, runs each test on each target, and writes the results to .e2e/report.json. ```sh npx e2e run ``` -------------------------------- ### Submit feedback via npx Source: https://docs.expo.dev/guides/using-e2e Use this command to submit feedback about the documentation. It requires an actionable feedback message and is the preferred method. ```bash npx --yes submit-expo-feedback@latest --category docs --subject "/guides/using-e2e/" "" ``` -------------------------------- ### Configure e2e.config.ts for iOS and Android targets Source: https://docs.expo.dev/guides/using-e2e Open e2e.config.ts and add a target for each platform. Set app.bundleId to your package name or bundle identifier, and set device in mobile() to the emulator or simulator to use. ```ts import type { E2EConfig } from 'e2e'; import { mobile } from '@e2e-dev/mobile'; export default { targets: [ { name: 'ios', engine: mobile({ platform: 'ios', device: 'iPhone 17 Pro', }), app: { bundleId: 'com.example.testerarmye2e' }, }, { name: 'android', engine: mobile({ platform: 'android', device: 'Medium Phone', }), app: { bundleId: 'com.example.testerarmye2e', appPath: 'android/app/build/outputs/apk/release/app-release.apk', }, }, ], workers: 1, } satisfies E2EConfig; ``` -------------------------------- ### Create iOS Simulator build with e2e-ios-simulator profile Source: https://docs.expo.dev/guides/using-e2e Build your app for the remote iOS Simulator using the `e2e-ios-simulator` profile. Record the build ID from the output. ```sh eas build --platform ios --profile e2e-ios-simulator ``` -------------------------------- ### Run an agent test with npx e2e run Source: https://docs.expo.dev/guides/using-e2e Runs the agent test file. On first run, the agent calls the model and saves actions to .e2e/cache; subsequent runs replay them without a model call. ```sh npx e2e run tests/agent.e2e.ts ``` -------------------------------- ### Create e2e.ci.config.ts with iOS target Source: https://docs.expo.dev/guides/using-e2e Defines an e2e configuration with one iOS target using the mobile engine. It does not set 'device' because the worker has one booted simulator. ```ts import type { E2EConfig } from 'e2e'; import { mobile } from '@e2e-dev/mobile'; export default { targets: [ { name: 'ios', engine: mobile({ platform: 'ios' }), app: { bundleId: 'com.example.testerarmye2e' }, }, ], workers: 1, } satisfies E2EConfig; ``` -------------------------------- ### Configure app identifiers in app.json Source: https://docs.expo.dev/guides/using-e2e Set android.package and ios.bundleIdentifier in your app config. e2e uses these values to open your app. ```json { "expo": { "ios": { "bundleIdentifier": "com.example.testerarmye2e" }, "android": { "package": "com.example.testerarmye2e" } } } ``` -------------------------------- ### List finished simulator builds Source: https://docs.expo.dev/guides/using-e2e Find a completed simulator build ID using `eas build:list` with the `--simulator` and `--status finished` flags. ```sh eas build:list --platform ios --simulator --status finished --json --non-interactive ``` -------------------------------- ### Submit feedback via curl HTTP fallback Source: https://docs.expo.dev/guides/using-e2e Use this command as a fallback to submit feedback via HTTP POST. It sends a JSON payload with the URL and feedback message. ```bash curl -X POST https://api.expo.dev/v2/feedback/docs-send -H 'Content-Type: application/json' -d '{"url":"/guides/using-e2e/","feedback":"🤖 Agent feedback for docs: (, )"}' ``` -------------------------------- ### Create e2e.eas.config.ts for EAS Simulator Source: https://docs.expo.dev/guides/using-e2e Configuration file that reuses e2e.config.ts and replaces targets with an iOS target using `easSimulators()`. Replace `` with your project ID. `videoTouches: false` disables touch indicators to save video. ```ts import type { E2EConfig } from 'e2e'; import { mobile } from '@e2e-dev/mobile'; import { easSimulators } from '@e2e-dev/eas'; import config from './e2e.config'; export default { ...config, targets: [ { name: 'ios', engine: mobile({ platform: 'ios', device: easSimulators({ projectId: '', buildId: process.env.IOS_SIMULATOR_BUILD_ID, }), videoTouches: false, }), app: { bundleId: 'com.example.testerarmye2e' }, }, ], } satisfies E2EConfig; ``` -------------------------------- ### Add iOS Simulator build profile to eas.json Source: https://docs.expo.dev/guides/using-e2e Adds an 'e2e-ios-simulator' build profile to eas.json with 'simulator' set to true for iOS, enabling simulator builds. ```json { "build": { "e2e-ios-simulator": { "ios": { "simulator": true } } } } ``` -------------------------------- ### Deep link test for iOS (tests/deep-link.e2e.ts) Source: https://docs.expo.dev/guides/using-e2e Tests that a deep link opens the explore screen on iOS. Handles the system 'Open in [app name]?' prompt by polling for the button and tapping it if present. ```ts test( 'deep link opens the explore screen on iOS', { platforms: ['ios'] }, async ({ device, screen }) => { const openInApp = screen.getByRole('button', { name: 'Open' }); const exploreIntro = screen.getByText('This starter app includes example', { exact: false }); await device.openLink('testerarmye2eexample://explore'); await expect .poll(async () => (await openInApp.count()) + (await exploreIntro.count())) .toBeGreaterThan(0); if ((await openInApp.count()) > 0) { await openInApp.tap(); } await expect(exploreIntro).toBeVisible(); } ); ``` -------------------------------- ### Deep link test for Android (tests/deep-link.e2e.ts) Source: https://docs.expo.dev/guides/using-e2e Tests that a deep link opens the explore screen on Android. Uses device.openLink() with the app's scheme and verifies the expected text is visible. ```ts test( 'deep link opens the explore screen on Android', { platforms: ['android'] }, async ({ device, screen }) => { await device.openLink('testerarmye2eexample://explore'); await expect( screen.getByText('This starter app includes example', { exact: false }) ).toBeVisible(); } ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.