Problem
A snapshot mismatch can overwrite its baseline without --update when the baseline filename ends in .PNG, has no extension, or uses another extension. Both the CLI's comparePngSnapshot() and the repository's comparePixelSnapshot() test helper have the same issue.
Their artifactPath() only replaces a lowercase .png suffix. Otherwise the actual and diff paths both equal the baseline path: the mismatch writes the actual image over the baseline, then overwrites it with the diff image.
Expected and actual behavior
A failed comparison should preserve the baseline byte-for-byte and write two separate diagnostic PNGs. On canary 9c23f6c0, six new regression cases fail: uppercase, extensionless, and other-extension filenames in each comparator. The lowercase .png, matching-image, and explicit-update cases already pass.
The CLI accepts --baseline <path> without an extension restriction; its bundled cli guide documents that option.
Reproduction and validation
The new packages/vgpu/tests/snapshot-png.test.ts uses temporary files and real PNG comparisons with one black baseline pixel and one white actual pixel. Run:
pnpm build
pnpm exec vitest run packages/vgpu/tests/snapshot-png.test.tsAgainst the original comparators: 6 failed, 6 passed. With the prototype: 12 passed. The tests check baseline bytes, actual pixels, a separate readable diff PNG, matching comparisons, and explicit updates.
Additional local validation:
- Focused regression, CLI, and tooling-readback suites: 44 passed.
pnpm test:fast: 1,413 passed, 77 skipped.pnpm typecheck: passed.- Strict standalone TypeScript check of the new test and its imported helpers: passed.
pnpm build: passed.pnpm migrations:check: passed.pnpm check:filenamesandgit diff --check: passed. The workspace has no general lint script.- Independent Astra xhigh review: no actionable findings; reviewer reran all 12 regression tests successfully.
No GPU is needed for these filesystem/PNG regressions. Docker rendering and the full GPU acceptance suite were not run.
Environment
Linux x64, Node 22.23.3, pnpm 9.15.4, frozen-lockfile dependencies, vgpu 0.6.0-rc.2 at canary 9c23f6c0.
Workflow and origin
External-contributor draft proposal, originating from an independent inspection of the snapshot comparators. No matching issue or PR was found in the repository search for snapshot baseline.
Under the current contribution policy, this is evidence and a prototype for maintainer triage and independent adoption in a separate implementation PR. It is not a maintainer integration PR. The existing release-impact type validator will reject contribution; the type is intentional.
Proposed approach
Strip a trailing .png case-insensitively, then always append .actual.png or .diff.png. Existing lowercase .png diagnostic names stay the same; other extensions are retained before the diagnostic suffix. Apply the same two-line change to both existing comparators, without introducing a shared abstraction.
For example, baseline.PNG produces baseline.actual.png and baseline.diff.png; baseline.bin produces baseline.bin.actual.png and baseline.bin.diff.png. Explicit updates still replace the baseline. An alternative would be to reject non-lowercase .png paths, but that would narrow the currently accepted input.
PR type
contribution
Activity
2This pull request is a draft
Merging is unavailable until it is marked ready for review.
@zanmlakar is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.