A small Flutter coffee-ordering app, tested end to end with e2e and built on Codemagic. e2e is an npm package, so the tests run on the build machine itself: a simulator on a Mac for iOS, an emulator on a Linux instance for Android. There is no server to host.
Try it
- Fork this repo and add it as an app in Codemagic.
- Create two empty variable groups on the app:
e2eandandroid_release. The workflows list them, and they stay empty until you add a key. - Start
e2e-iosande2e-android.
No accounts or secrets are needed. Seven tests run: six that find controls by test ID, and one where an agent orders a coffee. The agent step replays a recording committed in e2e/.e2e/cache/, so it needs no model and no key.
The agent test and the replay cache
An agent.act step asks a model to work through the app. The first run records what the agent did, and later runs replay those actions without a model call. The recording is plain JSON in e2e/.e2e/cache/. Read it before you trust it, as you would any test data. CI never writes to it.
The recordings were made once, locally, with Claude Code: one on an iPhone simulator and one on an Android emulator. Each belongs to this test, this instruction, one target and this bundle ID. That leads to three ways to use it:
-
Replay it. Do nothing. This is the default. Each workflow runs the agent test when it has a recording for its platform or a key.
-
Run it live. Add
AI_GATEWAY_API_KEY(secure) to thee2egroup and runnpx e2e run --no-cacheto see the model drive the app. The model is set ine2e/e2e.config.ts, and any AI SDK provider works. -
Record your own. Change the instruction, the app or the bundle ID, and the recording no longer matches. Either start the
record-cacheworkflow with a key set, which uploads a newe2e/.e2e/cacheas an artifact to commit, or record locally:terminal cd e2e E2E_AGENT=claude-code E2E_RECORD_CACHE=1 E2E_IOS_DEVICE=<simulator UDID> npx e2e run --target ios tests/agent.e2e.ts # Android: E2E_ANDROID_DEVICE=<emulator serial> ... --target androidE2E_AGENT=claude-codeuses your Claude Code login (claude auth login) instead of a key. If you would rather drop the recording, runnpx e2e cache clear. The test then skips until a key is set.
Skills for coding agents
The skills/ folder has two skills for Claude Code and other agents that read SKILL.md files:
skills/e2e-codemagic: adds e2e to a mobile app and sets up the Codemagic workflows, using this repo as the reference.skills/codemagic-build-loop: starts a Codemagic build through the REST API, waits for it, finds the failing step, reads its log and fixes the cause.
To use them in your own project, copy the folders into its .claude/skills/ folder. The build loop needs a Codemagic API token in CM_API_TOKEN and the app's id in CM_APP_ID.
Workflows
| Workflow | Runs on | What it does |
|---|---|---|
e2e-ios, e2e-android | push, pull request | Build the app, run the e2e suite, publish the JUnit report to the Tests tab |
release-ios, release-android | tag v* | Run the same e2e suite as a gate, then build the release |
record-cache | by hand | Record the agent test against a model and upload the recording |
Releasing
The release workflows build from a revision only after it passes the e2e suite. Out of the box they stop short of the stores:
- Android builds an app bundle, signed with the debug key.
- iOS builds an unsigned archive.
- The last step of each prints a message where the upload would happen.
To ship for real, the signing and publishing settings are already in codemagic.yaml as commented blocks. Each line starts with #| . Remove that prefix to enable a block. Codemagic code signing identities do the signing: you upload a certificate, profile or keystore once under Team settings, and the workflow refers to it by name. No keychain or keystore scripts are needed.
iOS
- Pick your own bundle ID and replace
io.codemagic.samples.beanlinein the Xcode project,android/app/build.gradle.kts,e2e/e2e.config.tsand thebundle_identifierline incodemagic.yaml. The agent test's recording belongs to the old ID, so re-record it or clear it, as described above. - Register the bundle ID and create the app in App Store Connect.
- Under Team settings, add your App Store Connect API key (Developer Portal), and upload a distribution certificate and an App Store provisioning profile for the bundle ID (Code signing identities).
- In
release-ios, put your key's name in theintegrationsblock. Enable theios_signing,integrationsandpublishingblocks and the two signed-build steps, and comment out the unsigned archive step.
Android
- Create the app in Play Console and upload a first build by hand.
- Upload your keystore under Team settings > Code signing identities, and enable the
android_signingblock with its reference name. - Add
GCLOUD_SERVICE_ACCOUNT_CREDENTIALS(secure) to theandroid_releasegroup, and enablepublishing.
python3 scripts/validate_yaml.py checks codemagic.yaml against the Codemagic schema twice, as shipped and with all #| blocks enabled, so the commented blocks stay valid.
Watch the gate stop a release
- In
e2e/tests/order.e2e.ts, change an expected value, for example the order number in the confirmation check. - Commit, then push a tag:
git tag v0.0.1 && git push origin v0.0.1. - The release workflow fails in the e2e step, the JUnit report names the failing test, and the build never reaches the release step.
Layout
lib/: the Flutter app.lib/semantics.dartgives every widget a stable test ID, which e2e finds withgetByTestId.e2e/: the tests ande2e.config.ts.codemagic.yaml: the five workflows.scripts/validate_yaml.py: schema check forcodemagic.yaml.skills/: agent skills for setting up e2e on Codemagic and running the build loop.
Building locally
flutter build ios --simulator --debug builds the app for a simulator. Xcode 27 needs an iOS deployment target of 15 or later, and Flutter 3.44 rejects its simulator framework's architecture order. The project already sets both: the target in the Xcode project and ARCHS[sdk=iphonesimulator*] = arm64 in ios/Flutter/Debug.xcconfig. The second setting suits Apple Silicon Macs only.
License
MIT. See LICENSE.
