Maestro
This page is for teams whose end-to-end tests are Maestro flows. It covers only what is different with Maestro. Getting started has the rest of the setup.
The examples use iOS, on a simulator in GitHub Actions. For Android, or for real phones on BrowserStack, see Other setups.
With Maestro, each flow file is one journey. KeepSnappy runs each flow on its own, 5 times per session by default. It compares each flow only with the same flow on main.
Install
The CI machine needs Maestro on its PATH. Init copies the job that runs your tests today, so a job that already installs Maestro keeps doing so. If yours doesn’t, copy the Install Maestro step of the CI example.
Maestro also needs the Java runtime that its own install guide names.
Settings in keepsnappy.yml
Init writes verdict_gate, app.bundle_id, flows.runner and flows.paths. The other settings are optional. keepsnappy.yml and run flags lists every setting.
verdict_gate: advisoryapp: bundle_id: com.example.appdevice: bootedflows: runner: maestro paths: - e2e/flows/*.yaml tags: [perf] exclude_tags: [flaky] maestro_version: '1.39.13'timeout_seconds: 600flows.paths: flow files, folders or globs. A folder means the flow files directly in it, without itsconfig.yaml.flows.tagsandflows.exclude_tags: a flow runs when it has one oftagsand none ofexclude_tags.flows.maestro_version: KeepSnappy writes it to the log, so you can see when Maestro changed. It doesn’t install or pick a version. Pin Maestro in CI yourself, because a new Maestro version changes how long its commands take.device: the simulator’s id (its UDID, fromxcrun simctl list devices booted), orbooted. If several simulators are booted and none is named, the run stops and lists them. KeepSnappy groups uploaded runs by simulator runtime.timeout_seconds: the longest that one run of one flow may take.
Only a flow file with a top-level appId: in its header runs as a journey. Helper flows without one, which you call with runFlow, are skipped. A helper with its own appId: runs as a journey too. To keep it out, tag your real flows and set flows.tags, or list the files.
A flow’s name: is its title on the dashboard. The first paragraph of the comment at the top of the file is its description. Journeys shows how to set both in keepsnappy.yml instead.
Variables your flows read
Maestro passes a flow only the environment variables whose names start with MAESTRO_. With runner: maestro, KeepSnappy runs each flow with no -e option. So a flow that reads ${APP_ID} in its appId: line gets no value.
Rename the variable in your flows to one that starts with MAESTRO_, such as ${MAESTRO_APP_ID}. Then set MAESTRO_APP_ID in the job’s environment.
If you run your own Maestro command (see the next section), you can add Maestro’s -e option to it instead. In keepsnappy run … -- <command>, the part after -- is the test command that KeepSnappy runs:
npx --no-install keepsnappy run --upload --wait -- maestro test -e APP_ID=com.example.app .maestroOne journey per flow, or one for the suite
Each flow gets its own result when KeepSnappy runs the flows itself. That is runner: maestro, with no command after -- in the workflow. Init sets it up this way when your job runs maestro test on the flows that keepsnappy.yml lists, with no options of its own.
Your whole suite is one journey, named e2e, in two cases:
- Your
maestroline has options of its own. Init keeps it after--in the workflow and says that the suite is one journey. - Your flows are in a Maestro workspace. Init keeps your Maestro command, so that Maestro applies the workspace’s selection and order. A new
keepsnappy.ymlstores the same command (flows.runneriscommand, andflows.commandruns Maestro on the workspace folder).
A workspace is a config.yml or config.yaml with flows:, includeTags:, excludeTags: or executionOrder:, in the flow folder or a folder above it.
Before measuring the workspace, check which flows it selects and in what order. Flows that sign up, post, delete content or change account settings can leave different data for the next run. For your first baseline, select a flow that can repeat on fixed data, or reset what it changes before each run. See Use the same data every run.
To get one journey per flow from a workspace:
- In the workflow, delete the
--and the command after it. - In
keepsnappy.yml, setflows.runnertomaestro, and deleteflows.command. - List the flow files in
flows.paths, or a folder that holds them directly.
Each flow then runs on its own, without the workspace’s selection and order. If flows.paths lists the workspace folder itself, keepsnappy doctor reports it and says what to use instead. To read init’s plan before it changes anything, run it with --detect.
Journeys that measure the same way
KeepSnappy compares a flow with itself across commits, so the flow must do the same work every time. Journeys has the rules for every test tool. In Maestro:
- Use the same data every run (why and how). To tell the app it is being measured, for example to use a mock server or a fixed date, pass a launch argument:
launchAppwitharguments:. Don’t setclearStatetotrue. It also clears what KeepSnappy keeps in the app’s data, and the run can be lost. - Start with
launchApp, so that every run starts from the home screen. Reset test data before the flow, not inside it. - Wait on a condition.
extendedWaitUntilwith atimeoutwaits for an element to show or go away. It fails the flow when that doesn’t happen. - Name elements by
id, which is the element’stestID. Usetextonly for content that has no other name. - Scroll with
swipeinside arepeat, with a fixed start, end andduration. Don’t usescrollUntilVisiblefor a measured scroll, because the number of gestures it sends depends on what is on screen. - End on the home screen, with the last screen closed.
# Opens the chat list, opens one chat, scrolls it, and goes back home.appId: com.example.appname: Scroll a chattags: - perf---- launchApp- tapOn: id: open-chat- extendedWaitUntil: visible: id: message-list timeout: 10000- repeat: times: 3 commands: - swipe: start: 50%, 80% end: 50%, 20% duration: 400- tapOn: id: back- extendedWaitUntil: visible: id: home timeout: 10000Step markers are optional, and results are correct without them. A step marker names a part of a journey, so the dashboard shows that part as a test step of its own (here chat.open). To name a step, copy node_modules/@keepsnappy/agent/maestro/keepsnappy/ into the folder of your flows. Then call its step.yaml at the start and at the end of the step.
appId: com.example.appname: Open a chat with step markers---- launchApp- runFlow: file: keepsnappy/step.yaml env: STEP: chat.open PHASE: start- tapOn: id: open-chat- extendedWaitUntil: visible: id: message-list timeout: 10000- runFlow: file: keepsnappy/step.yaml env: STEP: chat.open PHASE: endKeep file names stable. A renamed flow is a new journey, with no history on main. Change a flow in its own pull request: a pull request that edits a flow is compared with a main that ran the old flow.
CI example
Init writes a job like this for you, so copy this one only when init can’t use your job. Like the hand-made workflow, it runs the latest CLI release through npx and runs nightly at 03:00 UTC. It is one job on a macOS runner. It builds the app with the SDK, boots a simulator, installs Maestro and runs keepsnappy run.
name: KeepSnappyon: pull_request: push: branches: [main] # your default branch schedule: - cron: '0 3 * * *' workflow_dispatch:jobs: keepsnappy: runs-on: macos-15 timeout-minutes: 90 env: KEEPSNAPPY: '1' steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha || github.sha }} fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: '24' - run: npm ci - name: Boot a simulator run: | UDID=$(xcrun simctl list devices --json | jq -r '[.devices[][] | select(.name == "iPhone 16" and .isAvailable)][0].udid') xcrun simctl boot "$UDID" || true xcrun simctl bootstatus "$UDID" -b echo "SIMULATOR_UDID=$UDID" >> "$GITHUB_ENV" - name: Build and install the KeepSnappy build run: | npx expo prebuild --platform ios npx expo run:ios --configuration Release --device "$SIMULATOR_UDID" - name: Install Maestro run: | curl -fsSL "https://get.maestro.mobile.dev" | bash echo "$HOME/.maestro/bin" >> "$GITHUB_PATH" - name: Measure with KeepSnappy env: KEEPSNAPPY_KEY: ${{ secrets.KEEPSNAPPY_KEY }} run: > npx @keepsnappy/agent run --upload --wait --device "$SIMULATOR_UDID" --commit ${{ github.event.pull_request.head.sha || github.sha }}- The KeepSnappy step has no command after
--. It runs the flows thatkeepsnappy.ymllists. - A pull request gets its first real result once
mainhas 3 sessions (Getting started). - During the pilot, CI passes on a Worse (why).
- If your build and flows take longer than 90 minutes, raise
timeout-minutes(Budget the first session).
Known limits
- KeepSnappy measures what the app does. The time Maestro spends finding an element, or waiting between commands, is not part of it.
- KeepSnappy starts Maestro once per flow file in each run. Each flow starts from its own
launchApp. - A run whose flow fails does not count. A run with no tap doesn’t count either, because it has no screen to measure.
- Maestro finds simulators only in Xcode’s default device set. With a custom set (
--device-set,ios.device_setorSIMULATOR_DEVICE_SET_PATH), KeepSnappy stops a run that startsmaestro. Use a simulator in the default set, or another test tool (A custom simulator set).
Other setups
- iOS, on an iPhone on a cable: see On your Mac.
- Android, on an emulator in your CI: start with
keepsnappy init --detect. If init cannot use your emulator job, follow the manual Android setup. - Android, on a phone on a cable: Android has the steps by hand. On the emulator and the phone alike, KeepSnappy passes the device it picked to
maestrowith--device, so leave--deviceout of your command. - Real phones on BrowserStack, iOS or Android: these run through the
farmcommand, which runs a session on real phones in place ofkeepsnappy run. See BrowserStack and the CLI reference.
Troubleshooting lists what you may see with Maestro, and how to fix it.