Add precision/tolerance parameters to all snapshot APIs#316
Open
RoyalPineapple wants to merge 1 commit intomainfrom
Open
Add precision/tolerance parameters to all snapshot APIs#316RoyalPineapple wants to merge 1 commit intomainfrom
RoyalPineapple wants to merge 1 commit intomainfrom
Conversation
Pipe precision and tolerance parameters through all snapshot methods that previously lacked them, enabling developers to configure comparison sensitivity on every snapshot type. SnapshotTesting: Add `precision` and `perceptualPrecision` parameters to all Snapshotting factory methods (accessibility, inverted colors, hit targets, keyboard) across UIView, UIViewController, and SwiftUI strategies. Bump minimum SnapshotTesting dependency from 1.8.0 to 1.10.0 for perceptualPrecision support. iOSSnapshotTestCase: Add inline `perPixelTolerance` and `overallTolerance` parameters to all standard SnapshotVerify* methods. Deprecate the SnapshotImprecise* method family, which now delegates to the standard methods. This also fixes a bug where SnapshotImpreciseVerifyWithInvertedColors silently dropped tolerance parameters. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
priip
approved these changes
Feb 12, 2026
soroushsq
reviewed
Feb 19, 2026
Comment on lines
-123
to
-127
| func postNotification() { | ||
| NotificationCenter.default.post( | ||
| name: UIAccessibility.invertColorsStatusDidChangeNotification, | ||
| object: nil, | ||
| userInfo: nil |
Collaborator
There was a problem hiding this comment.
I see you wrote this in the description:
Fixes bug where SnapshotImpreciseVerifyWithInvertedColors silently dropped tolerance parameters
But I don't get why this notification goes away?
Comment on lines
+108
to
+113
| /// - parameter perPixelTolerance: The amount the RGBA components of a pixel can differ for the pixel to still be | ||
| /// considered "unchanged". Value must be in the range `[0,1]`, where `0` means no difference allowed and `1` means | ||
| /// any two colors are considered identical. | ||
| /// - parameter overallTolerance: The portion of pixels that are allowed to have changed (as defined by the | ||
| /// per-pixel tolerance) for the image to still considered "unchanged" overall. Value must be in the range `[0,1]`, | ||
| /// where `0` means no pixels may change and `1` means all pixels may change. |
Collaborator
There was a problem hiding this comment.
So if I'm reading this right, if either of these parameters is 0, then no difference is allowed? I.e. if you let a per pixel tolerance through, but the overall tolerance doesn't allow any pixels to be different, then the test will fail on any change?
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.
Pipe precision and tolerance parameters through all snapshot methods that previously lacked them, enabling developers to configure comparison sensitivity on every snapshot type.
SnapshotTesting changes:
precisionandperceptualPrecisionparameters to all Snapshotting factory methods (accessibility, inverted colors, hit targets, keyboard) across UIView, UIViewController, and SwiftUI strategiesperceptualPrecisionsupportiOSSnapshotTestCase changes:
perPixelToleranceandoverallToleranceparameters to all standard SnapshotVerify* methodsSnapshotImpreciseVerifyWithInvertedColorssilently dropped tolerance parametersBoth targets build cleanly with zero warnings.