assertSnapshot(of: Text("Hello"), as: .image) will not compile or give runtime crash due to missing frame
there is an ambiguity related to the extension in SnapShotting. There the .image for a SwiftUI view only exists if the format is a UIImage, but on macOS that does not exist
when running the current implementation requires a frame to be set on the SwiftUI view.
I added a test that runs on macOS and IOS and produces a snapshot. It uses ImageRenderer which is only available as of iOS 16 and also on macOS it requires at least 13. So using it is not a general solution. It however solves/bypasses the issues I had with making a simple snaphot of a swiftUI view.
I'm not sure this is a good solution or more of a workaround? But I think it might document a problem and could be a strategy for some?
assertSnapshot(of: Text("Hello"), as: .image)
will not compile or give runtime crash due to missing frameSnapShotting
. There the.image
for a SwiftUI view only exists if the format is a UIImage, but on macOS that does not existI added a test that runs on macOS and IOS and produces a snapshot. It uses
ImageRenderer
which is only available as of iOS 16 and also on macOS it requires at least 13. So using it is not a general solution. It however solves/bypasses the issues I had with making a simple snaphot of a swiftUI view.I'm not sure this is a good solution or more of a workaround? But I think it might document a problem and could be a strategy for some?
Might relate to issue https://github.com/pointfreeco/swift-snapshot-testing/issues/428, https://github.com/pointfreeco/swift-snapshot-testing/pull/533