swift-snapshot-testing
swift-snapshot-testing copied to clipboard
Add watchOS support
E.g. the .image
Diffing strategy is only available when #if os(iOS) || os(tvOS)
. This means the strategy is unavailable in os(watchOS)
targets.
It looks like one are that might prove tricky is the absence of CoreImage.CIKernel
on the watch. perceptuallyCompare
relies on this framework.
No perceptual precision, but otherwise I have something working here.
Just to confirm, there is no watchOS support in this snapshot testing for SwiftUI VIew's presently, right? E.g.,
assertSnapshot(of: view, as: .image(layout: .sizeThatFits))
works on iOS but will not compile on watchOS. i..e, I get the following
Cannot infer contextual base in reference to member 'sizeThatFits'
Generic parameter 'Format' could not be inferred
Type 'Snapshotting<ExampleView, _>' has no member 'image'
@cprince-foreflight That's right, the library itself doesn't support watchOS. This is because the feature that is used to compare images that only slightly differ uses API that isn't available on watchOS. In my comment above I link to a version that is based on another way to create the images, and lacks the ability to compare slightly different images, but does work on watchOS. I've not yet taken that PR out of draft as I haven't used it "in anger" since.