ios-snapshot-test-case
ios-snapshot-test-case copied to clipboard
different images on Intel and Apple M1
I'm seeing some tests with different binary image results on a Mac with Intel and a Mac with Apple M1. The diff image is all grey, so I guess it's just some bits.
Has anyone also seen this problem?
I've seen the same issue. I have to use Rosetta on the project to keep compatibility with CI and other team members.
The issue is well known and tracked here
This project already supports a perPixelTolerance
parameter, which behaves similarly to the swift-snapshot-testing PR linked in the above thread. I've found that setting this to 0.02
(2%) allows my snapshot tests to pass on both M1 and Intel.
Here's a convenience wrapper in Swift:
public extension FBSnapshotTestCase {
func FBSnapshotTolerantlyVerifyView(_ view: UIView, identifier: String? = nil, suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), perPixelTolerance: CGFloat = 0.02, overallTolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) {
FBSnapshotVerifyView(view, identifier: identifier, suffixes: suffixes, perPixelTolerance: perPixelTolerance, overallTolerance: overallTolerance, file: file, line: line)
}
}
And in Objective-C:
#define FBSnapshotTolerantlyVerifyView(view__, identifier__) \
FBSnapshotVerifyViewWithPixelOptions(view__, identifier__, FBSnapshotTestCaseDefaultSuffixes(), 0.02, 0)
Hope this helps!
This project already supports a
perPixelTolerance
parameter, which behaves similarly to the swift-snapshot-testing PR linked in the above thread. I've found that setting this to0.02
(2%) allows my snapshot tests to pass on both M1 and Intel.
This works for me, when the snapshot was created on an M1 I need to add 0.002
(0.2%) overallTolerance
as well.
We record screenshots in the same environment we verify them (i.e. we never record on developer devices). That solves the problem quite well.