Skip to content

Journeys

This page is for whoever writes your end-to-end tests. It says which tests become journeys, how they are named, and how to write them so that every run does the same work.

A journey is one end-to-end test that KeepSnappy repeats. With the command setting, your whole test command is one journey. KeepSnappy runs each journey 5 times per session by default (repetitions in keepsnappy.yml). Each journey gets its own result, compared only with the same journey on main.

Each test tool has its own page, with its install, its settings, a CI job and its limits: Maestro, Appium and e2e.

Use the same data every run

This is the most important rule for a journey. In every run, on every commit, the app must show the same data: the same account, the same content, the same date and the same settings.

Why

KeepSnappy compares how long each place of a journey takes on your pull request with the same place on main. How long a place takes depends on what the app draws there, and that depends on the data. A list of 50 rows draws more than a list of 10. A screen that shows an extra banner, section or chat draws extra components. When the data differs between sessions, the work differs too, and the place reads slower or faster although your code did not change.

In our own test app, on the same commit, a chat screen that showed a list of top chats in one session took about 70 ms longer than in the main sessions, where the list was empty.

How

Fix every input the app reads in the job that measures it:

  • Server data: point the measuring build at a mock server or at recorded responses. If the journey uses a real backend, give it a test account that only the journey uses, with fixed seed data, and reset that account before the app launches. If a journey changes server data, restore it before the next run.
  • Date, time and time zone: freeze the app’s clock at the same date and time, and use the same time zone on the phone in every run. Otherwise “today”, “2 minutes ago” and date headers change what the screen shows.
  • Feature flags and A/B tests: pin every remote flag and experiment to one value for the test account, or turn the remote fetch off in the measuring build.
  • List sizes and live content: give each list the same number of items. If the journey tests a live feature such as chat, a feed or presence, keep it on and make its content the same in every run. Drive it from a mock server or a recorded script that sends the same messages, in the same order and number, at the same moments relative to the journey’s steps, with no real users. Turn off only the live content the journey does not test, such as ads, counters fed by real users and A/B variants.
  • Language and region: use the same ones on the phone in every run.
  • Randomness: take random order, random picks and random delays out of the test and out of the measuring build, or give them a fixed seed.
  • One-time screens: onboarding, permission prompts, “What’s new” and rating prompts must show in every run or in none.

To tell the app it is the measuring build, use a build variable of your own that only the KeepSnappy job sets, or a launch argument from the test.

Reset data on your server or in your mock, not by clearing the app on the phone. KeepSnappy can keep its activation and the run’s measurements in the app’s data, so clearing the app or reinstalling it can lose the run.

Check your fixture backend

From the machine that runs the test, reset the fixture and read the responses the journey uses. Reset and read again. Compare the two sets of responses, including IDs, list order, pagination cursors and any timestamps shown in the app. Freeze timestamps assigned by the server as well as the app’s clock. A reset that creates new IDs or dates can still change what the app renders.

Check what the Release build calls after it launches, including when you scroll to the next page. If a mock handles the first page but later requests go to a live service, add those responses to the fixture before measuring. If resetting data signs out the test account, reset first, then sign in again before the measured journey.

What happens if you don’t

  • A false Worse: when your pull request’s session shows more content than the main sessions did, its places read slower, and the result can say Worse for a slowdown your change did not cause.
  • Real slowdowns hide: when the main sessions show different data from one another, their times spread out. KeepSnappy compares each component with its highest value in any main run, so a real slowdown smaller than that spread reads No change (Noisy places).
  • Less data hides a slowdown: when your pull request’s session shows less content than main, the work it saves can cover a real slowdown in your code.

Maestro flows

With runner: maestro, each flow file that flows.paths matches is one journey.

app:
bundle_id: com.example.app
repetitions: 5
flows:
runner: maestro
paths:
- e2e/flows/*.yaml

A path is a file, a folder or a glob. * matches inside one folder, and ** matches any number of folders.

A journey’s name is its flow’s file name without the extension. When two files have the same name, the journey’s name keeps the parent folder too. A renamed file is a new journey with no history on main, so keep file names stable.

The dashboard shows a title and a description for each journey. KeepSnappy reads both from the flow file. The title is its name:. The description is the first paragraph of the comment at the top of the file.

# Opens a chat with 200 messages and scrolls to the oldest one.
appId: com.example.app
name: Scroll a long chat
---
- launchApp

To set them in keepsnappy.yml instead, give the path as a map:

flows:
runner: maestro
paths:
- path: e2e/flows/chat.yaml
title: Scroll a long chat
description: Opens a chat with 200 messages and scrolls to the oldest one.

To pick flows by their Maestro tags, use tags and exclude_tags. A flow runs when it has one of tags and none of exclude_tags.

flows:
runner: maestro
paths:
- e2e/flows
tags: [perf]
exclude_tags: [flaky]

Any other test command

With runner: command, KeepSnappy runs your command as it is, for example an Appium suite. One command is one journey, however many tests it runs, so its tests don’t get a result each. The journey is named e2e, or by the name you give with --scenario, a flag of keepsnappy run.

flows:
runner: command
command: npx wdio run wdio.conf.ts

The command must exit 0 when the tests pass. A run whose command fails doesn’t count.

For a second journey, run a second keepsnappy run --scenario <name> -- <command>, in its own job. Each name has its own history on main. Only Maestro gives one journey per flow file.

e2e tests

With npx e2e run, KeepSnappy also reads the report.json that e2e (e2e.com) writes after every run, and a run that used AI or retried a test doesn’t count. e2e has the setup and the runs that don’t count.

Write journeys that measure the same way every run

KeepSnappy compares the same journey across commits. A journey that does different work from run to run makes that comparison noisy, and noise can hide a real slowdown. Use the same data every run keeps the app’s data the same. These rules keep a journey’s actions the same:

  • Start from the same state. Launch the app fresh, with the same data. Reset test data before the launch, not inside the journey.
  • Wait for a condition, never for a fixed time. Wait for an element to show or to go away. A fixed sleep is too short on a slow CI machine and wastes time on a fast one.
  • Give every wait a limit, and let a failed wait fail the test. Never wait and go on.
  • Find elements by testID. It is the fastest lookup, and it stays the same when the copy changes. A missing testID is a change to make in the app. Use text only for content that has no other name, such as a row of a list.
  • Look up each element once. A tap waits for its element itself, so a wait for the same element just before the tap is a second lookup. Check each step with one condition: something that shows only when that step worked.
  • Look up a list row inside its list, not over the whole screen.
  • With an Appium journey module, set tapSpacingMs when a control ignores a tap that comes too soon after the last one.
  • Scroll the same way every run: the same number of swipes, with the same length and speed. Don’t look for an element between two measured swipes.
  • Don’t relaunch the app or reset data inside the journey. A relaunch starts a new app process in the middle of the run, so the run also measures an app start and whatever the app loads again.
  • End on the home screen, with the previous screen closed. Then every run ends with the same work done.

Changing a journey changes what it measures. A pull request that edits a flow is compared with a main that ran the old flow. Make journey changes in their own pull request, apart from the app changes you want a result for.