Swiftpack.co - paulz/SwiftUI-snapshot-testing as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by paulz.
paulz/SwiftUI-snapshot-testing 2.1.1
Practical SwiftUI Snapshot Testing
⭐️ 4
🕓 50 weeks ago
iOS macOS
.package(url: "https://github.com/paulz/SwiftUI-snapshot-testing.git", from: "2.1.1")


Practical SwiftUI Snapshot Testing

Build and Test

  1. Compare Actual SwiftUI View with expected image with color accuracy
  2. Overwrite Expected with Actual on failure
  3. Attach Image Difference to test failure

This allows simple snapshot tests for SwiftUI views and previews.


Add Swift Package, add SwiftUI_SnapshotTesting to a project Test target.

Optionally add PreviewGroup to the app target, see Preview Group


See Example iOS app project with SnapshotTests.swift

func testViews() {
    verifySnapshot(Text("SwiftUI").foregroundColor(.red), "example")

Documentation is on Wiki


Stars: 4
Last commit: 48 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.


Release Notes

Release 2.1.1
50 weeks ago

enhancement #22 - generate simple default name for snapshots

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics