ViewInspector
ViewInspector copied to clipboard
Xcode hangs on same cases.
I am experiencing strange issue.
Xcode hangs after I run the following "Test" Version 12.0.1 (12A7300)
import SwiftUI
struct ContentView: View {
@StateObject var vm = ContentVM()
var body: some View {
VStack {
ForEach(vm.items, id: \.self) { title in
Button(title) {
vm.showText = title
}.padding(.vertical, 5)
}
}
}
}
class ContentVM: ObservableObject {
@Published var showText: String?
let items = ["A1", "A2", "A3"]
}
import XCTest
import ViewInspector
import SwiftUI
@testable import AnotherCheck
extension ContentView: Inspectable {}
class AnotherCheckTests: XCTestCase {
func testButton() throws {
let sut = ContentView()
let k = try sut.inspect().vStack()
}
}
The issues has something to do with the @StateObject.
@agiokas have you tried async inspection? I didn't have time yet to add tests and fully explore @StateObject, but from my current understanding it's closer to "@State" than to "@ObservedObject", so I would try the async inspection instead.
Feel free to reopen the ticket if the suggestion above did not work for you