Skip to content

Instantly share code, notes, and snippets.

@cupnoodle
Created June 20, 2018 11:18
Show Gist options
  • Save cupnoodle/eaf20be54af0fff7fe74246d74175338 to your computer and use it in GitHub Desktop.
Save cupnoodle/eaf20be54af0fff7fe74246d74175338 to your computer and use it in GitHub Desktop.
Swift unit test with delay to wait the UI to present
let alertExpectation = XCTestExpectation(description: "testAlertShouldAppear")
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
XCTAssertTrue(loginVC.presentedViewController is UIAlertController)
alertExpectation.fulfill()
})
wait(for: [alertExpectation], timeout: 1.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment