aegzorz/stilleben
Modern snapshotting
Examples
Example of snapshot testing a SwiftUI view:
import XCTest
import Stilleben
final class SomeViewTests: XCTestCase {
private let matcher = UIMatcher()
.assertSimulator(modelIdentifier: "iPhone14,7")
.sizing(.dynamicHeight)
.dynamicTypeSizes(.large)
func testSomeView() async throws {
await matcher
.colorSchemes(.light)
.match {
NavigationView {
SomeView()
}
}
}
}<details> <summary>Generated snapshot</summary> <img src="https://user-images.githubusercontent.com/810539/202294178-d2cbc7b4-fe3c-409e-8d2c-d445a100f8c0.png" width="200px"> </details>
It also supports snapshot testing UIKit view controllers or views:
import XCTest
import Stilleben
final class SomeViewControllerTests: XCTestCase {
private let matcher = UIMatcher()
.assertSimulator(modelIdentifier: "iPhone14,7")
.sizing(.screen)
func testSomeViewController() async throws {
await matcher
.match { @MainActor () -> UIViewController in
SomeViewController()
}
}
func testSomeView() async throws {
await matcher
.sizing(.intrinsic)
.match { @MainActor () -> UIView in
SomeView()
}
}
}Support for snapshotting reflections of your models:
import XCTest
import Stilleben
final class ReflectionTests: XCTestCase {
let matcher = ReflectionMatcher()
func testSimpleModel() async {
struct Model {
let text = "Hello World!"
}
await matcher.match {
Model()
}
}
}Which yields a text file snapshot:
▿ StillebenTests.ReflectionTests.?.?.Model
- text: "Hello World!"Package Metadata
Repository: aegzorz/stilleben
Stars: 0
Forks: 0
Open issues: 2
Default branch: main
Primary language: swift
License: MIT
README: README.md