Basically the problem is the same as this one: XCTestCase: Wait for app to idle
I am using perpetually repeating \"background animations\" in my views. The !@#$#$&@
Unfortunately using Apple's UI Testing you can't turn 'wait for app to idle' or poll other network activity, however you can use environment variables to disable animations in your app to make the tests more stable. In your setup method before your test set an environment variable like this.
override func setUp() {
super.setUp()
continueAfterFailure = false
let app = XCUIApplication()
app.launchEnvironment = ["UITEST_DISABLE_ANIMATIONS" : "YES"]
app.launch()
}
Now in your source code:
if (ProcessInfo.processInfo.environment["UITEST_DISABLE_ANIMATIONS"] == "YES") {
UIView.setAnimationsEnabled(false)
}
You can place that check in a specific view if you only want it to disable animations for that specific view or in a delegate file to disable animations throughout the app.