skip to content

[ agent view ]

raw .md[ view as human ]

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.

Continuous integration

Run e2e on GitHub Actions, GitLab CI/CD, Expo Workflows, Bitrise, Codemagic, Norrix, or any CI service that runs Node.

e2e runs on each CI service that can run Node 24.8 or later (22.22.3 or later on Node 22), or Bun 1.4.3 or later for web tests. Each job installs the dependencies, starts the app or a device, runs the tests, and uploads .e2e/.

Pick your CI service

<CardGroup cols={2}>
<Card title="GitHub Actions" icon="/images/integrations/github-actions.svg" href="/ci/github-actions">

Web and mobile workflows. Post the results as a pull request comment.

</Card>
<Card title="GitLab CI/CD" icon="/images/integrations/gitlab.svg" href="/ci/gitlab">

Web and mobile jobs. Show the results in the merge request.

</Card>
<Card title="Expo Workflows" icon="/images/integrations/expo.svg" href="/ci/eas-workflows">

Build an Expo app with Expo Build, then run iOS and Android tests on it.

</Card>
<Card title="Bitrise" icon="/images/integrations/bitrise.svg" href="/ci/bitrise">

iOS and Android workflows with the Bitrise steps for simulators and emulators.

</Card>
<Card title="Codemagic" icon="/images/integrations/codemagic.svg" href="/ci/codemagic">

iOS and Android workflows on Mac mini and Linux instances.

</Card>
<Card title="Norrix" icon="/images/integrations/norrix.png" href="/ci/norrix">

Build a NativeScript app with Norrix, then run its suite on a Norrix simulator or emulator.

</Card>
</CardGroup>

For another CI service, copy the GitHub Actions workflow. To lease browsers or devices from a hosted service, see Hosted browsers and devices.

Upload the reports

Upload .e2e/ at the end of each job, also when a test fails. It holds:

PathWhat it holds
report.jsonThe run report, from each run that reaches its tests
junit.xmlWith the junit reporter (--reporter list,junit): the results, the tests a test filter left out as skipped, and startup failures such as APP_UNREACHABLE in a run suite
results/The trace pages, screenshots, and screen dumps of each test. With --video, also a video for each target whose engine can record

Point the test-report integration of your CI service at .e2e/junit.xml. On GitLab, junit.xml also links each failure screenshot, so it shows in the test report. The output option moves .e2e/.

Model credentials

Give the job the credential your provider needs, such as AI_GATEWAY_API_KEY (see Models). Tests that never use agent need none.

<Warning>

Each job that has the key gives it to the code it runs: tests, config, and dependencies. Give the key only to builds of branches you trust. Run untrusted pull request code with no secrets and no write tokens. See Security.

</Warning>

Keep keys in CI secrets, and set spending limits where you can. GitHub does not give secrets to pull requests from forks.

What CI changes

CI mode is on when CI has a value other than an empty string, 0, or false. To get these defaults locally, run CI=1 npx e2e run:

SettingLocalCI
retries01
workershalf your cores1
cache when unsetread-writeread-only
.onlyallowedrejected with ONLY_IN_CI
command.reuseExistinghonoredignored, with a notice

To change the worker and retry defaults, use flags:

<CodeGroup>
npx e2e run --workers 4 --retries 0
pnpm exec e2e run --workers 4 --retries 0
bunx e2e run --workers 4 --retries 0
</CodeGroup>

To send no telemetry from CI, add E2E_TELEMETRY_DISABLED: '1' to the env of the job.

Mobile jobs

Without a hosted device service, each platform needs its own machine, build, and device:

iOSAndroid
MachinemacOS with Xcode and a simulator runtimeLinux with KVM (nested virtualization)
BuildRelease simulator .app, no signingRelease .apk
DeviceA booted simulatorA booted emulator

Make a Release build on both platforms. A React Native or Expo debug build loads its JavaScript from Metro, which these jobs don't start, so it opens on an error screen. The examples use a React Native project with ios/ and android/ in the repository. For an Expo project without them, run npx expo prebuild first.

Install the build, then run the suite:

<CodeGroup>
# iOS
xcrun simctl install booted path/to/MyApp.app
npx e2e run --target ios --reporter list,junit

# Android
adb install -r path/to/app.apk
npx e2e run --target android --reporter list,junit
# iOS
xcrun simctl install booted path/to/MyApp.app
pnpm exec e2e run --target ios --reporter list,junit

# Android
adb install -r path/to/app.apk
pnpm exec e2e run --target android --reporter list,junit
# iOS
xcrun simctl install booted path/to/MyApp.app
bunx e2e run --target ios --reporter list,junit

# Android
adb install -r path/to/app.apk
bunx e2e run --target android --reporter list,junit
</CodeGroup>

The commands assume two targets named ios and android, each a mobile() engine with the app's bundleId. See Point at your app. To let the suite install the build, set app.appPath and call device.installApp().

These rules apply on each service:

  • One job for each platform. Run --target ios on a Mac and --target android on Linux with KVM. Hosted Macs use Apple Silicon, which can't nest virtualization, so the Android emulator doesn't start on them.
  • Boot the device in its own step. With no device booted, the engine asks agent-device to boot one, but a new Linux runner has no emulator image. A separate step also tells a failed boot from a failed test.
  • Pin the iOS runtime. A simulator picked by name (iPhone 17) runs the image's default iOS, and the accessibility tree changes between iOS releases. A runner image update can then fail a locator assertion with no change in your code. The examples create a simulator on a named runtime and boot it by UDID. Replace iOS-26-5 with a runtime the image has (xcrun simctl list runtimes).
  • Cache ~/.agent-device/apple-runner/derived. agent-device builds its XCUITest runner there the first time it drives a simulator. Don't cache all of ~/.agent-device. The rest is the state of the last daemon, and a restored copy can stop the next run with Failed to communicate with daemon.
  • Replay local recordings. The replay cache key holds the app, not the device, so a step recorded on your simulator replays on the CI one. Commit the replay cache.

Gate pull requests

Each non-zero exit fails the job, a failed agent step included. To block merges on a failed run, make the e2e job a required check. Debugging a run lists each exit code and whether rerunning the job can help.

To keep the checks predictable:

  • Give each agent.act one atomic goal. Then check its result with a locator assertion or agent.assert.
  • Commit the replay cache. A replayed agent.act makes no model call. With the built-in agent, a cache miss, a hand-off, and every agent judgment (agent.assert, agent.waitFor, agent.extract) call the model.
  • Watch for flaky tests. The report marks a test that passes only on the CI retry as flaky.
  • Add --max-failures <n> to stop the run after that many failed tests, so a broken deploy doesn't spend a model call on each remaining step. The job exits 1.
  • Add --max-duration <ms> to limit test-running time; the clock starts when tests start, not during app startup. The job exits 1.

Run only affected tests

On a pull request, pass --changed-since so a test filter can leave out the tests the change is unlikely to affect. When the filter scores tests, as the decision filter does, each target starts the files of the likeliest to fail first. Without the flag, as on main, the whole suite runs. See Add the decision filter.

With the CI default of one worker, only the relevance bands order files and collection order breaks ties: e2e reads the timings history only with more than one worker. See Start the likeliest first.

Cache the timings history

With more than one worker, e2e run starts the longest files first, after any file it has no time for, ordered by <output>/timings.json (.e2e/timings.json by default): a few KB that a run updates when it ran at least one file whole. A fresh CI checkout has none, so restore it from your CI cache before the run and save it after. GitHub Actions has the step.

  • The file is advisory. One that is missing, corrupt, or invalid is no history, and the run falls back to the previous report.json. A restored file can change the order of files, never a result.
  • A run times a file only when it ran all of it. A --grep or --last-failed run leaves the entry of a file it ran in part as it was.
  • CI defaults to one worker. Set workers or pass --workers to benefit.
  • Key the cache by branch, with main as the fallback, so a new pull request starts from the history of main. With sharding, add the shard index to the key.
  • --timings <file> reads and writes another path.

Sharding

--shard <index/total> runs one slice of the suite. Every job runs the same command with its own index, and every machine slices the suite the same way. A shard with no test fails with NO_TESTS. If a matrix can have more shards than tests, add --pass-with-no-tests. The CLI reference has the slicing rules.

On GitHub Actions, a matrix runs one job for each shard:

jobs:
  e2e:
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3]
    steps:
      # ...
      - run: npx e2e run --shard ${{ matrix.shard }}/3 --reporter list,junit

Upload each shard's report.json and junit.xml under a name with the shard index. e2e can't merge shard reports yet.

Rerunning failures

--last-failed runs only the tests that didn't pass in the previous run, read from report.json in the output directory. Run it in the same step as the first run:

      - run: npx e2e run || npx e2e run --last-failed

The rerun keeps the first run's artifacts and writes its own under rerun-<n>/ in each test's directory, so one upload holds both. The CLI reference lists what counts as not passed.

A separate job has no report on its runner. Download it into the output directory first, or rerun the failed job.

Next

<CardGroup cols={2}>
<Card title="Pull request comments" icon="code-pull-request" href="/github">

One comment per run, edited in place on a rerun.

</Card>
<Card title="CLI reference" icon="terminal" href="/reference/cli">

Flags, reporters, and every exit code.

</Card>
</CardGroup>