snapshot in a check’s expect compares the screen the check ends on to a baseline image, with no model.
Add a snapshot to a check
Add these keys to an existing check file:needs_review. Inspect the image before you commit it. Later runs compare against that baseline.
Baselines are PNGs in .mobster/snapshots/<check>/<name>@<device>-<appearance>-<content_size>-<locale>.png, for example .mobster/snapshots/settings/settings@iphone-17-pro-dark-accessibility-extra-large-default.png. A condition the check doesn’t set reads default. <check> is the check file’s path under .mobster/checks, without the suffix. Commit them: they are the expected screens.
Read a changed snapshot
- No baseline for this device and these conditions. Mobster saves the screen as the baseline and the check ends
needs_reviewwith “baseline recorded”. It never fails a check for a missing baseline. Look at the PNG, commit it, and the next run compares to it. - A baseline. Mobster takes a full-size PNG after the screen settles and compares it to the baseline.
- The same size, within the threshold. The snapshot passes.
- Over the threshold. The check fails with class
finding, the message says how much of the screen changed, and the run folder holdssnapshots/<name>-diff.png: the screen faded, with the changed pixels red. - A different size. The check fails and says both sizes. A baseline belongs to one device, so another device gets its own baseline.
--update-snapshots. Mobster writes the baseline whatever the screen shows, and the snapshot passes. With--check NAMEit updates only the checks with that name or file name. Read the diff of the PNGs in your pull request before you commit.
threshold percent of the unmasked pixels changed (default 0.1).
Mobster leaves out:
- Your masks. An
idorlabelmask covers every shown element it matches. Arectis in points. Masked pixels count in neither the changed pixels nor the total. - The keyboard. While the keyboard shows, Mobster masks it and the text fields on screen, because a caret blinks.
- The status bar. On a simulator, Mobster sets 9:41, full battery, full signal and Wi-Fi for the run (a
status_barcondition of yours wins) and puts it back afterwards. On a real iPhone it can’t, so it masks the status bar.
Accept an intended change
After you inspect the diff, update only the check whose screen you meant to change. For a check namedsettings:
Clean up old baselines
mobster test snapshots marks each baseline current, stale (its check still has the snapshot, but not for this appearance, text size or locale) or orphaned (no check has that snapshot). Mobster lists them and deletes nothing: remove them with git rm.
In results.json, a result with a snapshot has snapshot with name, status (matched, changed, size_changed, recorded or updated), changedPercent, thresholdPercent, regions and masks as [x, y, width, height] in pixels, size, diffMs, and the absolute paths of the baseline, current and diff images. junit.xml lists the same paths in the case’s <system-out>, so a CI system can attach the diff. The run’s own report shows the three images side by side.