-
Hello! I am trying to use the library in combination with Swift Testing and async functions. It works great for simple views, but I am having trouble using views that rely on the struct MyView: View, in {
@Environment(\.test) var test: Test
let inspection = Inspection<Self>()
var body: some View {
Text("stuff")
}
let sut = MyView()
try await ViewHosting.host(sut.environment(\.test, Test()) { hostedView in
try await hostedView.inspection.inspect { view in
#expect(throws: Never.self) {
_ = try view.find(viewWithAccessibilityIdentifier: a11yIdEmptyJobListText)
_ = try view.find(text: "empty text")
}
}
} But then the problem is that the environment view modifier erases the type of Did anybody manage to work around this problem? |
Beta Was this translation helpful? Give feedback.
Answered by
nalexn
Nov 22, 2024
Replies: 1 comment 2 replies
-
Hey, yeah, I found this isn't properly documented, so you can do let sut = MyView()
try await ViewHosting.host(sut.environment(\.test, Test()) { _ in
try await sut.inspection.inspect { view in
#expect(throws: Never.self) {
_ = try view.find(viewWithAccessibilityIdentifier: a11yIdEmptyJobListText)
_ = try view.find(text: "empty text")
}
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
adusak
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, yeah, I found this isn't properly documented, so you can do