swift-snapshot-testing
swift-snapshot-testing copied to clipboard
Improve warning about view snapshot discrepancies
I think it's better to be conservative, as the list of variables that can cause discrepancies is incomplete and unlikely to ever be exhaustive.
Other things that seem to cause differences:
- The architecture of the Mac running the simulator causing subtle "sub" pixel differences
- Optical font sizing adjustments that either don't respect the
displayScale
UI trait or deliberately ignore it because it's truly driven by the device display's points per inch (a product of the display's scale and pixels per inch) - Changes to system fonts between iOS versions (lose fit, but added to emphasize the need for a snapshot strategy to be run on multiple devices, unless only one iOS version is targeted)
I think a broad caution is more prudent than extending the warning to include more device characteristics, as even if that list could be complete now, it would be very hard to track.
More alternatives, same as the proposed in this PR but removing the emphatic/redundant "exact":
⚠️ Warning: Snapshots must be compared using the same simulator that originally took the reference to avoid discrepancies between images.
Strengthened to also mention the architecture of the hosting Mac:
⚠️ Warning: To avoid discrepancies between images, snapshots must be compared using the same simulator and Mac system architecture (i.e. Apple Silicon vs. Intel) that originally took the reference image.