Open pinarol opened 3 weeks ago
Let's check how we can add unit tests for SwiftUI Views.
We can try snapshotting with the existing snapshot library, like:
func testMyViewSnapshot() { // Create the SwiftUI view let view = MyView() let hostingController = UIHostingController(rootView: view) hostingController.view.frame = CGRect(x: 0, y: 0, width: 200, height: 100) assertSnapshot(matching: hostingController, as: .image) }
Let's check how we can add unit tests for SwiftUI Views.
We can try snapshotting with the existing snapshot library, like: