flutterware
All guides
Screens and tests

Comparison

See what a branch changed on screen before you merge it. fw compare renders your previews, replays your scenarios and photographs your server's pages on both your branch and its base, then reports every screen that moved: the pixels, the widget tree, the visible text and the events the app recorded.

There are no golden files to keep up to date and nothing to approve. Both sides are built from git when you ask, so the base is always the real base.

A comparison in the studio: the previews that changed on a branch, and the
        menu open on both sides

Run it#

fw compare                         # against the default base
fw compare --base=origin/release   # against any ref git can name
fw compare --entry='demo/shop.dart#shopMenu'

The base is the one set in tool/flutterware.dart (fw.changes(ChangesConfig(base: …))), or else origin/HEAD, main or master, whichever exists first.

Entries whose code the branch didn't touch are skipped without being rendered, so a branch that changed no widget code finishes almost at once. A scenario only your branch has is replayed on your branch, so its screens are in the report.

Pages are a third tab, one row per sample and viewport, such as site/home@phone. A page's tree is its accessibility tree. Pages says how to serve them.

The result lands in an index.json (its path is printed last) and on the Changes screen of the studio, beside the diff. Each changed screen shows both sides and what differs between them.

On a pull request#

fw compare --export                          # a browsable page, in build/comparison/web
fw compare --report=build/comparison-report  # what a PR comment needs

--export writes a static page (a viewer, the index.json and one PNG per frame) that works from any web host, including a per-PR folder. Serve it over HTTP; opened as a local file it can't load its own frames.

The page lists what looks different first. A change that left the picture the same, such as a new widget around an old one, is labelled same picture and folded under one line. A small change is drawn zoomed in, both in that list and in the comment's mosaic.

Clicking a changed scenario in that list opens the step it pictures. On a step, Next change and Previous change (the double arrows) skip the steps that did not change.

On the previews, scenarios and pages tabs, click a channel such as pixels to list only what changed there, and click it again to list everything. Filter hides a channel instead.

When most of the rows share one change, a line above the list names it. Hide same pictures takes off the rows that have the same picture and show no other change, and lists them under hidden by rules. Rows whose picture changed stay. Filter brings the hidden ones back.

--report writes a comment.md and a mosaic.png of the screens that look different, base beside head, with the exported page under web/. Entries are named as on the page, and the comment's table says which file each is in. Both list the changes several findings share, such as one widget replaced by another in every screen. The comment uses __MOSAIC_URL__ and __VIEWER_URL__ placeholders, for your workflow to replace once it has uploaded the files. A change that left the picture the same is counted apart, as 1 same picture in the heading, and its row says what did change, such as same picture · events. The table's change column gives how much of the frame moved, the step to open and how many other steps changed, or the change in words. When nothing looks different there is no mosaic.png.

In CI#

fw compare exits 1 only when a side produced no answer at all, for example when the base doesn't build or a pages command never printed its port. Changed screens don't fail it: a branch is supposed to change things. To gate on changes, read index.json; package:flutterware/comparison_report.dart reads it, typed.

With pages, cache the Chrome the first run downloads (see Pages) so each run doesn't fetch it again.

Reference#

fw help compare, and the fw commands in the capabilities reference.

Edit this page on GitHub