Fix: Support for snapshot tests on Intel and M1 #1094
Merged
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.
Why?
As mentioned in the iOS meeting yesterday the snapshot tests would not run successfully on M1, since there's a small color difference between the architectures when rendering shadows and cornerRadius.
The issue is described here:
pointfreeco/swift-snapshot-testing#313
pointfreeco/swift-snapshot-testing#424
As we discussed there's an open PR that masks this issue by allowing pixels to have a slightly different value, which will work for us until we're all on M1 sometime™. Since it's not merged yet we will point to @pimms fork (thank you!) until it is or we figure out another solution.
subpixelThreshold
will make sure that the color channel values (RGBA) of all pixels are within the threshold. I.e. the snapshot tests won't fail if the reference pixel is #000000FF and the produced pixel is #040404FF.PNG issue
After setting this up yesterday some tests were still failing, and I noticed that there is a tiiiiiny difference in placement when it comes to rendering some PNG images.
Kapture.2022-02-10.at.11.59.04.mp4
I'm not sure of the reason and if this applies to all PNGs, or just those with different sizes (@1x, @2x, @3x), but I reached out to Sanjin and got an updated icon in PDF to use when we need a placeholder.
What?
SnapshotTesting
to https://github.com/pimms/swift-snapshot-testingsubpixelThreshold
to 5..noImage
with an updated PDF.Version Change
Minor. No breaking changes.
UI Changes