A extension to SnapshotTesting that adds a SwiftUI snapshot strategy using SwiftUI.ImageRender
to snapshot the View
.
Once installed, no additional configuration is required. You can import the ImageRenderSnapshotStrategy
module, call into SnapshotTesting
following their usage guide but provide the .imageRender
strategy as below.
import XCTest
import SnapshotTesting
import SnapshotTestingImageRender
class ContentViewTests: XCTestCase {
func testSnapshots() {
let view = ContentView()
assertSnapshot(matching: view, as: .imageRender)
}
}
⚠️ Warning: By default, Xcode will try to add the SnapshotTestingImageRender package to your project's main application/framework target. Please ensure that SnapshotTestingImageRender is added to a test target instead, as documented in the last step, below.
https://github.com/john-flanagan/SnapshotTestingImageRender
If you want to use SnapshotTestingImageRender in any other project that uses Swift Package Manager, add the package as a dependency in Package.swift
:
dependencies: [
.package(url: "https://github.com/john-flanagan/SnapshotTestingImageRender.git", from: "1.0.0"),
]
Next, add SnapshotTestingImageRender
as a dependency of your test target:
targets: [
.target(
name: "MyApp"
),
.testTarget(
name: "MyAppTests",
dependencies: [
.target(name: "MyApp"),
.product(name: "SnapshotTestingImageRender", package: "SnapshotTestingImageRender"),
]
),
]
This library is released under the MIT license. See LICENSE for details.
link |
Stars: 7 |
Last commit: 9 weeks ago |
Initial Release
Full Changelog: https://github.com/john-flanagan/SnapshotTestingImageRender/commits/1.0.0
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics