Part 3 of a series about building VisTest, an open-source visual regression library for pytest and Playwright. Part 2 was about measuring the engine with a ruler I drew myself. This one is about replacing the ruler.
TL;DR
- I built a frozen corpus from six pages rendered by Chromium, with changes and expected answers written down before measuring the engine.
- On the September 2026 corpus, the old VisTest engine missed 132 of 276 real changes. Playwright's default comparator missed 103. At
threshold: 0.05, it missed 22. - My engine produced fewer false failures, but it was throwing away entire families of real changes: text colors, underlines, focus rings.
- Making the screenshots repeatable took work of its own. Even a mutation applied at the wrong moment could change the pixels.
- The useful result was a list of things the engine could not see, and a way to check whether a fix helped on pages it had not been tuned on.
The table I did not want to publish
At the end of the previous article, I had run a small probe on one Chromium page. It was enough to make the synthetic benchmark uncomfortable. It was not enough to replace it.
One page still lets me choose the layout, the changes and the explanation afterwards. I needed more pages, a repeatable capture, and rules I could not quietly move when the numbers arrived.
Here is where that led:
| Tool and setting | False failures, out of 48 noise pairs | Missed changes, out of 276 signal pairs |
|---|---|---|
| VisTest, balanced | 34 | 132 |
Playwright, default (threshold: 0.2, maxDiffPixels: 0) |
42 | 103 |
Playwright, threshold: 0.05, maxDiffPixels: 0
|
42 | 22 |
These are historical results from 28 September 2026, before engine v2. VisTest was measured with OpenCV 4.13.0; the native Playwright comparator was 1.63.0. The recorded command was python tests/benchmark.py --corpus browser --no-timing --markdown docs/benchmark_browser.md. The archived table and development journal preserve this stage. Running the command on today's engine measures today's engine, not this table.
My default missed nearly half the real changes. Playwright's stricter setting caught far more of them, while failing on eight more noise pairs.
There is no single winner hidden in those two columns. But there was a very clear problem with the product I was building.
Six pages, with the answers written first
The new corpus started with six small local pages: an orders table, a settings form, product cards, a landing page, a long serif article and a dark dashboard.
They were still pages I wrote. This was not a random sample of production websites, and rendering them in Chromium did not make them independent of every assumption I had. It did remove one important dependency: OpenCV no longer drew the pictures that my OpenCV-based engine was being judged on.
The frozen Chromium baselines, shown as thumbnails. These are the corpus pages, not illustrations of them.
Each page had targets for the same families of changes. Repaint a button. Change a link color. Add an underline. Remove a border. Change one character. Move a block. Make text bold. Remove an element.
The expected answer came from the operation that made the screenshot. If I changed one character, the pair was a real change whether my engine found it or not.
Some cases needed a human decision. I made those decisions before measuring:
| Change | Corpus label |
|---|---|
| Color difference around ΔE00 2 | DISPUTED |
| A block moved by 1 px | SIGNAL |
| Opacity reduced to 0.98 | NOISE |
| Letter spacing increased by 0.2 px | SIGNAL |
Those labels are a policy, not a law of vision. A design-system test might care about that opacity change. Another team might accept the spacing change. What mattered here was that my engine's answer did not get a vote in the label.
DISPUTED cases stayed in the corpus and in the output, outside the score. I wanted to see how the tools treated them without turning a borderline judgment into a claimed win.
Even the color changes had a separate ruler. The generator calculated them with its own implementation of CIEDE2000, checked against published reference pairs, rather than importing the engine's color-distance function. After rounding colors to eight bits, it recorded the distance it actually produced.
The previous corpus had taught me what happens when the generator and detector share the same mistake.
Before testing the engine, I had to test the camera
What I thought. Local HTML, a pinned Chromium, no network. Take a screenshot and move on.
What happened. Two fresh browsers could draw different pixels for the same case.
The control was simple: draw each frame in two separately started browsers. If the pictures differed, stop. A frame that could not reproduce itself had no business deciding whether a comparator was correct.
That control caught three problems before the benchmark caught anything useful about the engine.
First, applying a mutation after page load was too late. Depending on timing, Chromium could paint before or after the change. A fill mutation came out seven pixels different in the second browser. Moving the mutation to DOMContentLoaded, before the first paint, made the operation repeatable.
Second, rendering styles needed to exist from the first paint too. A fractional shift on the dark page sometimes differed between captures. Waiting longer afterwards did not fix the fact that the two pages had started rendering differently.
Third, a focus outline on a text input could move a corner pixel between frames. The corpus used a button for that mutation instead. The purpose was to measure whether an engine detected a focus ring, with a frame whose pixels were repeatable.
There was a quieter mistake as well. The first version of a movement case changed margin-top. On the article template the margin collapsed, and the target did not move. The final case used padding. A line of CSS saying “move this” is not evidence that anything moved.
A bundled font is not proof that it was used
The pages shipped their fonts. They loaded nothing from the network. I gave the font families their own names so a locally installed font would not accidentally take their place.
Then I asked Chromium which fonts it had actually drawn.
One character, ›, had fallen back to Liberation Sans.
The stylesheet was correct. The screenshot was not using only the fonts I thought it was using. Checking the fonts through Chrome's DevTools Protocol caught what checking the CSS could not.
The environment record grew accordingly: operating system, architecture, Playwright version, Chromium version and build, viewport, device scale factor, and the fonts actually used on each page.
Even browser.version was not enough to distinguish the full Chromium executable from its headless shell. They could report the same version and render text differently. The record needed the browser product string as well.
I was building a benchmark for image comparison and spending my time proving where an image came from. That turned out to be part of the benchmark.
Noise had to exist in the pixels
The noise cases kept the content and changed how it was rendered: hinting, text rendering, fractional page shifts, the full browser instead of the headless shell.
Changing a browser flag was not enough to earn a case. If it produced exactly the baseline pixels, it was recorded as having no effect and left out of the pairs.
Otherwise I could improve the noise score by adding easy “noise” cases with no differences to detect.
The first frozen set contained 276 signal pairs, 42 noise pairs and 18 disputed pairs. Adding six Windows baselines later brought the noise count to 48. The table at the start includes that addition.
The Windows frames used the same Chromium build and the shipped fonts, with the same viewport and scale. They still differed from Linux. Every tested setting of both tools failed on all six pairs.
That result also put a limit on the earlier one-page probe. In that probe, several renderer variations had produced identical pixels. Here, with different pages and bundled web fonts, some of those variations changed the pictures substantially.
“This flag did nothing on my page” had been true. “This flag produces no rendering noise” would not have been.
Why I kept two pages out of reach
Four templates were for calibration: table, form, cards and article. Landing and dark were held out.
The split was by page, not by screenshot pair.
If I tuned a rule on a button from the landing page, then tested it on another mutation of the same button, I would still be looking at the same geometry, background and fonts. A random split of pairs would make the test set look separate while carrying much of the training material into it.
Holding out entire templates was a stronger question: does the rule help on a page it did not get to learn?
It was not a permanent certificate. Once a held-out result influenced my next choice, that page was no longer an untouched test of the next idea. A folder named “held-out” cannot enforce that distinction for you.
The manifest stored the split with each pair. The test suite checked it. The remaining part was discipline: choose on the calibration pages, then measure the held-out pages.
Playwright got more than one setting
It would have been convenient to compare only defaults. My default had fewer false failures, and I could have led with that column.
Instead, the benchmark ran Playwright's native comparator over a grid: three pixel thresholds and four allowed pixel counts. The recorded comparator was the one used by toHaveScreenshot(), not a Python approximation of it.
Those two settings buy different things. Lowering threshold makes the comparison sensitive to smaller color differences. Raising maxDiffPixels lets more changed pixels through before the check fails.
The second setting does not know whether those pixels belong to noisy text or a real underline. It just counts.
That is why the report kept false failures and misses separate. A setting that saves some noisy checks by hiding more real changes has made a trade, and the table should show both sides of it.
The browser used to capture the corpus was Python Playwright 1.56.0 with Chromium 141.0.7390.37. The comparator was Playwright 1.63.0. Those are different roles and different recorded versions: one produced the images, the other compared the frozen pairs.
The useful part was below the headline
The summary told me the engine had a problem. The table by change family told me where to look.
The old balanced engine missed every text-color, link-color and icon-color case. It missed every added underline, focus ring and removed border.
These were not all subtle changes at the edge of perception. The color families included ΔE00 15.
On the failures inspected in the journal, the changed pixels existed in the intermediate mask. They did not survive into a region. The engine returned zero regions for a real change it had already seen.
Baseline on the left, the frozen underline mutation on the right. Identical crops enlarged 4× with nearest-neighbor scaling; no pixels retouched. The historical family table records that VisTest missed this family on every template.
That was a different diagnosis from “the threshold needs adjusting.” A threshold at the end cannot recover evidence discarded earlier in the pipeline.
The cascade had accumulated ways to keep checks green: consensus between color and structure, anti-aliasing suppression, morphological cleanup, minimum sizes. Each had a reason. Together, on real browser text and thin edges, they could erase the thing the tool existed to find.
Making the preset stricter helped some cases. It did not make that design sound.
What this corpus could still not prove
The renderer was real. The pages and mutations were mine.
Six local pages do not represent every application. The labels encode my decisions. A corpus with many rendering variations does not tell you how often those variations occur in a team's pinned CI environment. Its false-failure percentage is a percentage of these deliberately selected pairs, not a forecast for your next thousand tests.
And a comparison of frozen images does not measure the entire screenshot-testing experience: waiting for the application, dealing with animation, choosing baselines, reading a failure and deciding what to accept.
This corpus gave me a better experiment. Calling it “real browser” did not make it the real world.
What changed after the cold shower
I stopped treating fewer red checks as evidence of a better engine on its own.
The next design started from a different requirement: keep the visible differences, then ask which ones a specific rule can explain. A difference should not disappear just because it is small or inconvenient to classify. If a rule sets it aside, the result should name that rule.
That became engine v2. The installed library today uses it by default; the old-engine table above is the reason for the rewrite, not a report on the current release.
The rewrite and its remaining failures deserve their own article. This stage ended with the engine untouched and a much less flattering measurement of it.
That was progress. I finally had a benchmark capable of telling me to stop.
If you are building a testing tool, try one thing before adding the next feature: take a failure family your own tests barely cover, write down the expected answers, and measure it without changing the implementation. Keep the table even if it makes the launch post harder to write.
Try it on a page I did not write
If your team already has screenshot tests, you probably have a better next experiment than another page I could add to my corpus: your own baseline/actual pairs.
You can try the current engine on those pictures before changing any tests:
pip install vistest
vistest bench --expected baselines --actual screenshots
The two folders should contain matching file names. If you already use Playwright Test, vistest bench test-results reads its output layout instead.
The command writes a local HTML report showing where VisTest and Playwright disagree. The Playwright comparison needs Node.js and an installed @playwright/test; --no-playwright runs VisTest alone. The screenshots stay on your machine.
Pick a few pairs where you know what happened: an intentional UI change, a rendering difference that wasted your time, a defect your old check missed. Look at the explanation as well as the verdict. Would it have helped you decide what to do?
I'm looking for a few teams using pytest and Playwright to try this on an existing project. If that sounds useful, leave a comment or open an issue with your setup and what you found. You do not need to post private screenshots; a description is enough to start. I'd like to help investigate the disagreements, including the ones where VisTest is wrong.
The next useful result is a check someone else understands and keeps running. Another green table on my own pages cannot tell me that.
Next: rebuilding the engine so a difference needs an explanation before it can disappear.


Top comments (2)
Your two-browser control reminded me of a smaller control we use for SVG edits: open and save the file without touching it. In one test, the editor rewrote the path curves and Edge rendered exactly the same pixels. Comparing the actual edit against that saved copy made it much easier to see what the edit itself changed.
Thanks for sharing this. I like the save-without-editing check. In my case, I ran the same capture twice to see whether the browser produced the same pixels. In yours, the SVG changed on disk while the rendered image stayed identical. Using the re-saved copy as the baseline makes it much easier to see what the actual edit changed.