Practical SwiftUI Snapshot Testing
SwiftUI-snapshot-testing
Practical SwiftUI Snapshot Testing
- Compare Actual SwiftUI View with expected image with color accuracy
- Overwrite Expected with Actual on failure
- Attach Image Difference to test failure
This allows simple snapshot tests for SwiftUI views and previews.
Installation
Add Swift Package to a project Test target
Example
See Example iOS app project with SnapshotTests.swift
func testViews() {
verifySnapshot(FavoriteView_Previews.self)
verifySnapshot(ContentView())
verifySnapshot(Text("SwiftUI").foregroundColor(.red), "example")
}