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
⭐️ 5
🕓 1 year ago
iOS macOS
.package(url: "https://github.com/paulz/SwiftUI-snapshot-testing.git", from: "2.1.1")

SwiftUI-snapshot-testing

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.

Installation

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

Optionally add PreviewGroup to the app target, see Preview Group

Example

See Example iOS app project with SnapshotTests.swift

func testViews() {
    verifySnapshot(FavoriteView_Previews.self)
    verifySnapshot(ContentView())
    verifySnapshot(Text("SwiftUI").foregroundColor(.red), "example")
}

Documentation is on Wiki

GitHub

link
Stars: 5
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Release Notes

Release 2.1.1
1 year ago

enhancement #22 - generate simple default name for snapshots

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