I'm implementing a test case using Quick/Nimble making network request (URLRequest) but I'm getting this error:
*** Terminating app due to uncaught exception 'InvalidNimbleAPIUsage', reason: 'expect(...).toEventually(...) can only run on the main thread.'
This is my test case:
expect(someVar).toEventually(equal("bar"), timeout: 0.2, pollInterval: 0.1, description: "time")
If change my implementation:
DispatchQueue.main.async {
expect(someVar).toEventually(equal("bar"), timeout: 0.2, pollInterval: 0.1, description: "time")
}
I get this error:
*** Terminating app due to uncaught exception 'InvalidNimbleAPIUsage', reason: 'Nested async expectations are not allowed to avoid creating flaky tests.
Any of you has an idea how can make this test case to work using Quick/Nimble
?
I'll really appreciate your help