assert_visual
Compare a screen region against a baseline PNG to detect visual changes and avoid whole-screen flakiness. Explicitly update the baseline when needed.
Instructions
Compare the current screen, or a region of it, against a baseline image.
Region comparison is the reason this is usable. A whole-screen baseline on a device with a clock in the status bar differs on every single run, which is how visual testing earns its reputation for flakiness. Cropping to the part that matters is what makes the result mean something.
update_baseline exists so refreshing a baseline is an explicit, visible act
rather than an edit someone makes by hand and forgets to review.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device | No | Device serial. Omit to take any single free device. | |
| region | No | [left, top, right, bottom] in pixels to compare. Omit to compare the whole screen. | |
| baseline | Yes | Path to the baseline PNG to compare against. | |
| tolerance | No | Fraction of differing pixels still considered a match. | |
| update_baseline | No | Overwrite the baseline with the current screen and pass. |