Quick / Nimble

A Matcher Framework for Swift and Objective-C
https://quick.github.io/Nimble/documentation/nimble/
Apache License 2.0
4.8k stars 601 forks source link

Run SyncExpectation's expression in async contexts of toEventually on the main actor. #1044

Closed younata closed 1 year ago

younata commented 1 year ago

This PR prevents a main thread checker error.

Basically, the following test would actually fail prior to this PR:

@MainActor
func test_example() async {
    await expect(Thread.isMainThread).toEventually(beTrue())
}

which, if you replace the Thread.isMainThread part, with, say, checking a UIKit API, could cause a test crash due to the main thread checker causing crashes when run in debug mode.