Compare SVG snapshot pixels instead of raw bytes - #4711
Merged
rushabhcodes merged 1 commit intoSep 11, 2026
Conversation
imrishabh18
approved these changes
Sep 11, 2026
Contributor
|
Thank you for your contribution! 🎉 PR Rating: ⭐⭐ Track your contributions and see the leaderboard at: tscircuit Contribution Tracker |
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.
SVG snapshot checks can fail even when the rendered board is unchanged. Asynchronous footprint loading can change generated IDs and the order of independent SVG elements; the AP3429A snapshot failure in tscircuit/sparkfun-boards#328 is one example. Plain
tsci snapshotcompares raw buffers, and the image comparator used by--ci/--testalso falls back to byte equality for SVG input because it only decodes PNGs.Render differing SVGs to PNGs with the existing Resvg helper before comparing them. Use this visual comparison for normal checks as well as checks that produce diff artifacts. Identical buffers take a fast path, and explicit
--updatewithout diff generation continues to refresh metadata and other nonvisual SVG text. SVG mismatch artifacts remain SVG files; PNG diff generation is preserved.Regression coverage verifies that changed IDs, comments, and reordered non-overlapping elements pass, while changed colors and reordered overlapping shapes fail. CLI tests cover normal,
--ci, and--testchecks, explicit updates, and real visual mismatches. The captured AP3429A SVG pair has different bytes and compares equal with this change.The comparison uses the SVG's native rendered dimensions and the existing tolerance of 2. This makes snapshot validation visual; it does not promise to detect subpixel geometry changes or make Circuit JSON generation deterministic.
Validation on current upstream main:
git diff --checkpassed.