So I'm attempting to run an XCode UI Test on my React Native project. My goal is to use fastlane/snapshot to grab screenshots of my app.
I finally figured out how to script my app to do what I want. Unfortunately, the app gets stuck with an App failed to quiesce within 60s
message after calling app.otherElements["mainButton"].tap()
.
As far as I can tell as a human, my app appears to be static and not updating or animating anything. But I'm not clear what the UI Test is using for its detection heuristic, so it might be using some internal state or checking threads.
I suspect there's some React Native behavior that's keeping the UI Test from seeing things as finished. Unfortunately, without any real ability to see what UI Tests are doing, I'm not even sure where I need to dig into React Native to fix it. :(
Any help would be appreciated!
The workaround from link above For the view having issues and a line to disable animations in
viewWillAppear:
- (void) viewWillAppear: (BOOL)animated {
if ([[[NSProcessInfo processInfo] environment][@"UITEST_DISABLE_ANIMATIONS"] isEqualToString:@"YES"]) {
[UIView setAnimationsEnabled:NO];
}
}
and in viewWillDisappear turn animations back on:
- (void) viewWillDisappear:(BOOL)animated {
if ([[[NSProcessInfo processInfo] environment][@"UITEST_DISABLE_ANIMATIONS"] isEqualToString:@"YES"]) {
[UIView setAnimationsEnabled:YES];
}
}
In your tests extend XCUIApplication and set variables. Then in your setup method call that launchvariables function
extension XCUIApplication {
func launchTestsWithEnvironmentVariables() {
launchEnvironment = [
"UITEST_DISABLE_ANIMATIONS" : "YES"
]
self.launch()
}
}
override func setUp() {
super.setUp()
continueAfterFailure = false
XCUIApplication().launchTestsWithEnvironmentVariables()
}
func testblahblah {
This sets an environmental variable that will disable animations for that particualr view. Only downside is you won't be testing animations for that view if thats something your into. Hacky workaround but it works for now.
PS it really helped for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With