Chromium drew a blue underline under a link. VisTest picked up the changed pixels. The test passed anyway.
I built VisTest to catch visual regressions in Python Playwright tests. In part 3, a benchmark made from Chromium screenshots showed how often my engine missed real changes. This one underline showed me where to look.
Where the line went
I traced the changed pixels through the old engine. They made it into the first map of differences. Then a cleanup step erased the thin line before it could become a region the engine would report. By the time VisTest decided whether to pass, there was nothing left to judge. Development journal
A stricter setting at the end of that pipeline had nothing to work with. I rewrote the part that decided which pixels made it that far.
What v2 does with the same screenshot
The new engine groups changed pixels into regions first. Then it looks for a specific reason to set a region aside. One rule checks whether slightly different text edges can be explained by how the browser drew the same letters. When a rule suppresses a region, the result records which rule did it.
On those same two PNGs, v2 fails the check and tells me where to look.
changed: 57x1 at (37, 182): line added: 57×1 px, #2563eb
The same crop from the baseline, the changed screenshot and the diff VisTest generated.
There are still false alarms. A chart drawn at a fractional pixel offset can come back with different edges and fail a check even when the data is the same. Those cases are in the VisTest guide.
Run the same comparison
Save the baseline and changed screenshot in one directory. The example uses VisTest 0.2.0a5 and OpenCV 5.0.0.
pip install vistest==0.2.0a5
vistest compare base.png underline--on.png
The command exits with code 1 for this pair and writes the diff to vistest-diff/. You can also give it two screenshots of your own. For pytest and Playwright, there's a runnable example of the same comparison in a test with expect_screenshot(). VisTest on GitHub
If you've ever had a screenshot test stay green after a visible UI change, what did it miss?
Originally published on Hashnode. Drafted with AI using the VisTest development journal and a verified CLI run.

Top comments (0)