iosswiftquick-nimble

Swift Quick/Nimble - Wait for predicate to match


I'm trying to convert the following block of code to Quick/Nimble with no success whatsoever

XCTWaiter().wait(for: [XCTNSPredicateExpectation(predicate: NSPredicate(format: "height == 0"), 
                                                 object: vc.myView.frame)], 
                 timeout: 1)

I tried the following but the test does not pass

waitUntil(timeout: 2) { done in
    expect(vc.myView.frame.height).to(equal(0))
    done()
}

Thx in advance for your help!


Solution

  • You can also set the timeout globally, e.g. once your tests start, so it applies for all toEventually calls:

    Nimble >= 9.0.0

    Nimble.AsyncDefaults.timeout = .seconds(2)
    

    Nimble < 9.0.0

    Nimble.AsyncDefaults.Timeout = 2