Closed LostStudent closed 5 months ago
Hey @LostStudent, that error means the compiler can't resolve the method signature. The assertSnapshot
method is defined by SnapshotTesting, while the accessibilityImage
strategy is defined by AccessibilitySnapshot.
ah adding a hosting controller works.
func testExample() throws {
let host = UIHostingController(rootView: ContentView())
host.view.frame = .init(x: 0, y: 0, width: 100, height: 100)
assertSnapshot(
matching: host,
as: .accessibilityImage(showActivationPoints: .always,
drawHierarchyInKeyWindow: true),
named: "shot"
)
}
should the previous usage have worked? My test project imports AccessibilitySnapshot using swift package manager in xcode. AccessibilitySnapshot is added as a dependency of the test target the imports in my test file are:
import XCTest
import SnapshotTesting
@testable import accessSnaps
import SwiftUI
import AccessibilitySnapshot
Ahh, that's expected. Try updating to version 0.7. Prior versions didn't support snapshotting SwiftUI views directly, requiring a hosting controller instead.
Hey Id love to give this a try but im having trouble using the accessibilityImage .
when I use SnapshotTesting's assert:
that takes a snapshot.
But when I try to use the accessibilityImage strategy :
I get compile error: "Type of expression is ambiguous without a type annotation" is this trying to use SnapshotTesting's assert rather than AccessibilitySnapshot's?