pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.
https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing
MIT License
3.74k stars 570 forks source link

Run snapshot test directly in Swift Package Manager (SPM) containing SwiftUI views #732

Open XRadevFRT opened 1 year ago

XRadevFRT commented 1 year ago

Greetings everyone! The title pretty much says it all. Im currently exporting the UI in a SwiftPM and because there are already XCTest I was wondering if there is a way to directly snapshot the UI in the package...

mltbnz commented 1 year ago

You can set up and run the tests from your package.

You can take a look here:

https://github.com/criticalmaps/criticalmaps-ios/tree/main/CriticalMapsKit/Tests/StyleguideTests

XRadevFRT commented 1 year ago

@mltbnz

Thank You! By chance, I managed to make them work. But still, your answer is beneficial to me.

One thing I couldn't do, however, is to generate images for the failing tests... Help will be much appreciated! 🍻

mltbnz commented 1 year ago

I think I don't know what you referring to. If you mean the failure screenshot when a test fails you will see them in Xcode

image