Skip to content

Comments

Add precision/tolerance parameters to all snapshot APIs#316

Open
RoyalPineapple wants to merge 1 commit intomainfrom
RoyalPineapple/precision-plumbing
Open

Add precision/tolerance parameters to all snapshot APIs#316
RoyalPineapple wants to merge 1 commit intomainfrom
RoyalPineapple/precision-plumbing

Conversation

@RoyalPineapple
Copy link
Collaborator

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:

  • Add precision and perceptualPrecision parameters to all Snapshotting factory methods (accessibility, inverted colors, hit targets, keyboard) across UIView, UIViewController, and SwiftUI strategies
  • Bump minimum dependency from 1.8.0 to 1.10.0 for perceptualPrecision support

iOSSnapshotTestCase changes:

  • Add inline perPixelTolerance and overallTolerance parameters to all standard SnapshotVerify* methods
  • Deprecate the SnapshotImprecise* method family, which now delegates to the standard methods
  • Fixes bug where SnapshotImpreciseVerifyWithInvertedColors silently dropped tolerance parameters

Both targets build cleanly with zero warnings.

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>
@RoyalPineapple RoyalPineapple marked this pull request as draft February 12, 2026 12:40
@RoyalPineapple RoyalPineapple marked this pull request as ready for review February 12, 2026 12:43
Comment on lines -123 to -127
func postNotification() {
NotificationCenter.default.post(
name: UIAccessibility.invertColorsStatusDidChangeNotification,
object: nil,
userInfo: nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants