Conversation
Move decode / pad / encode in compareImagesTask from pngjs (pure JS, per-scanline filter heuristic on every write) to sharp, which is already a runtime dependency. Same-size images reuse the bytes already in memory, so only the diff gets encoded on the success path. Pixel data and diff results are unchanged; base64 snapshot tests are replaced by structural assertions. BREAKING CHANGE: Node.js 20.9 or newer is now required (sharp 0.35 already needed it, the engines field was stale). PNG files written by the plugin are now encoded by sharp/libvips, so their bytes differ from 4.x output while pixels are identical; existing baselines keep working. When compared images differ in size, the padding now uniformly covers the whole added area. pngjs is no longer a dependency. For migration guide, go to this link: https://github.com/FRSOURCE/cypress-plugin-visual-regression-diff/blob/main/packages/cypress-plugin-visual-regression-diff/MIGRATION.md#4x---5x Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Batch Review Mode (added as opt-in in 4.2) is now on unless it is explicitly turned off. Reading of pluginVisualRegressionBatchReviewMode and pluginVisualRegressionBatchReviewModeShowPassingImages moves from support.ts and an inlined copy in commands.ts into config.utils.ts, so both the FAB/carousel hooks and matchImage() share one getter and one default. Example configs drop the now-redundant opt-in, README describes how to disable the mode instead of how to enable it, and MIGRATION.md gets a 4.x -> 5.x entry. BREAKING CHANGE: matchImage() no longer fails the test on the first mismatch. Failing snapshots are collected and a single error with the failure count is thrown once the spec finishes (in headed mode they can be reviewed and approved in bulk from the plugin's floating button). To keep the 4.x behaviour, set pluginVisualRegressionBatchReviewMode to false via `expose` (Cypress >=15.10) or `env` (older Cypress). For migration guide, go to this link: https://github.com/FRSOURCE/cypress-plugin-visual-regression-diff/blob/main/packages/cypress-plugin-visual-regression-diff/MIGRATION.md#4x---5x Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The plugin package (15.21.1), examples/webpack (15.18.0) and examples/next (13.14.2) now all develop against Cypress 16.1.0. Cypress 16 removed the `--env` CLI flag and `Cypress.env()` in favour of `--expose` / `Cypress.expose()`, so the example scripts and the demo recording script pass plugin options via `--expose`. Cypress 14+ also dropped the `cypress/react18` mount entry point; the Next.js example now mounts from `cypress/react`. The peerDependency range (`cypress >=13.0.0`) is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
cypress.demo.config.ts exists only for scripts/record-batch-demo.mjs, so it now lives next to that script instead of in the end-user example. The recorder passes the config's absolute path via --config-file while keeping examples/next as the project root, and the config imports initPlugin from the built workspace package. cypress is added to the root devDependencies so the config resolves it from scripts/ (the root previously held a stale auto-installed 13.x peer). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Cypress 16 removed `Cypress.env()` from its type definitions, which broke the plugin build (TS2339 in config.utils.ts) once the devDependency was bumped. The legacy fallback for Cypress <15.10 now goes through a narrow local type instead of the removed declaration. The examples/next e2e baselines are re-rendered with Cypress 16 so a local `cypress run` compares cleanly again; CI keeps running the example with pluginVisualRegressionUpdateImages=true as before. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
FRSgit
force-pushed
the
feat/major-5
branch
from
September 21, 2026 13:21
93ed4f2 to
d6e8c3f
Compare
Drop pngjs-era shapes that survived the sharp migration: - scaleImage takes and returns a buffer instead of writing the resized PNG to disk and reading it back, only for compareImagesTask to write the same file again - getImageSize reads dimensions from the PNG header, and decodePNG decodes straight to the common size (extend is a no-op for same-size images), so mismatched images are decoded once instead of twice and padImageToSize is gone - Buffers are passed straight to pixelmatch and fs.writeFileSync; the Uint8Array view helper and the extra copy of the stamped screenshot are removed, addPNGMetadata returns a zero-copy Buffer - isImageOfTestType parses PNG metadata once instead of twice per file, writePNG is inlined at its single call site The Buffer typing issues that forced the old helpers came from the deprecated @types/glob stub pulling in @types/node 18. Replace it with an explicit @types/node 20.x (matching engines) and reference it in tsconfig; examples/next gets the same pin. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
FRSgit
added this pull request to stack #419
September 21, 2026 23:49
FRSgit
removed this pull request from stack #419
September 21, 2026 23:52
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
…#421) Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two breaking changes for v5: image comparison no longer goes through
pngjs, and Batch Review Mode becomes the default.sharp replaces pngjs
compareImagesTaskdecodes, pads and encodes withsharp(already a runtime dependency). pngjs's default write tried all five PNG filters per scanline in JS and accounted for most of the comparison time; sharp's native path is many times faster and unaffected by V8 coverage instrumentation.pngjs,@types/pngjs, and the deprecated stubs@types/sharpand@types/pixelmatchare removed.Batch Review Mode on by default
pluginVisualRegressionBatchReviewModeandpluginVisualRegressionBatchReviewModeShowPassingImagesare now read by shared getters inconfig.utils.ts. Previouslysupport.ts(FAB, carousel, hooks) andcommands.ts(matchImage, inlined) each read the flag on their own.false(or the string"false"from the CLI).examples/nextconfigs drop the now-redundant opt-in; README's "How to enable" becomes "How to disable";MIGRATION.mdgets a new entry.Breaking changes
Batch Review Mode is the default.
matchImage()no longer throws on the first mismatch. Failing snapshots are collected and a single error with the failure count is thrown once the spec finishes; in headed mode they can be reviewed and approved in bulk from the plugin's floating button. To keep the 4.x behaviour, setpluginVisualRegressionBatchReviewMode: falseviaexpose(Cypress >= 15.10) orenv(older Cypress). Projects that already set it totruecan drop the option.Node.js >= 20.9.0. sharp 0.35 already required it; the
enginesfield was stale.PNG bytes change. Files written by the plugin are now encoded by libvips. Existing baselines keep working and are only rewritten when updated.
DIFF_IMAGES_VERSIONstays1because the comparison algorithm is unchanged.Uniform padding. When compared images differ in size, the added area is now fully filled with
rgba(0, 0, 0, 64); 4.x left the first padded row/column transparent due to an off-by-one. Diff results are unaffected.Migration notes:
packages/cypress-plugin-visual-regression-diff/MIGRATION.md, section4.x -> 5.x.Tests
New
config.utils.test.tscovers the expose/env fallback, the batch-mode default, and disabling viafalse/"false"on both Cypress APIs.support.test.tskeeps only thelocalStorageprecedence tests.Base64 PNG snapshots (72 KB, coupled to encoder output) replaced by structural assertions: decode with sharp, check dimensions, check that same-size images are passed through untouched.
New
image.utils.test.tscovers decode (RGB → RGBA), encode round trip, padding pixels, andscaleImageAndWrite(previously untested).Integration suite with coverage: test body time 818 ms → 146 ms.
Cypress
examples/nextandexamples/webpack: component and e2e suites pass with Batch Review Mode on by default (no explicit option in either config); a plain comparison run against committed baselines passes; a forced size mismatch fails correctly and writes a stamped.diff.pngat the padded size.Other changes
>=13unchanged). Example scripts use--expose, the Next.js example mounts fromcypress/react, and the legacyCypress.env()fallback goes through a local type since Cypress 16 typings dropped it.scripts/cypress.demo.config.ts(used only by the demo GIF recorder) moved out ofexamples/next.🤖 Generated with Claude Code