wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.23k stars 1.92k forks source link

Add a configuration setting to allow the setTimeout limit to be more than 1.5 seconds #2123

Open christianchown opened 4 years ago

christianchown commented 4 years ago

Is your feature request related to a problem? Please describe. Currently, an expect() will fail if a setTimeout() is enacted that is longer than 1.5 seconds, as the documentation states here

The current workaround is to swap out expect() for a combination of waitFor() and withTimeout(). As the documentation states, you should only use waitFor/withTimeout as a last resort.

Describe the solution you'd like For there to be an additional launchApp configuration setting that allows for a different setTimeout limit

Additional context From a very quick scan of the code, I think the currently hard-coded constants for the timeout setting are here:

iOS: https://github.com/wix/Detox/blob/57300d5970b6facf1468f2abc59e8fab641404c2/detox/ios/Detox/WXJSTimerObservationIdlingResource.m#L114

Android: https://github.com/wix/Detox/blob/d8cf10e375188ae55980b3fea36022674b6f08eb/detox/android/detox/src/main/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt#L10

LeoNatan commented 4 years ago

We are working on removing usage of Earl Grey on iOS, so we might be able to squeeze this soon.

In the meantime, mock your code to limit whatever it is you have with long timers to be limited to 1.5 seconds.

christianchown commented 4 years ago

Thanks, that would be great if you can squeeze it in. In the meantime, we've done what you've suggested

d4vidi commented 4 years ago

@christianchown it's not entirely accurate - that an expect would fail in this state (namely, with a timer set to >1.5sec from "now"). It's a rule-of-thumb threshold we use for assessing whether an app is Idle (e.g. following an action). Do you have a specific use case in mind where this breaks a test, in particular?

LeoNatan commented 4 years ago

@d4vidi The 1.5 time cutoff is used for every timer fired by the app. So if an animation is fired that takes longer than 1.5 seconds to finish, Detox will ignore it and proceed with the test, thus resulting in a failure.

d4vidi commented 4 years ago

@LeoNatan Aren't animation monitored independently on iOS, as on Android?

LeoNatan commented 4 years ago

Native animations are. But RN isn’t native in any sense of the word, especially JS “animations”.

d4vidi commented 4 years ago

Yes that's what I meant. I understand that's a no.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

stale[bot] commented 2 years ago

The issue has been closed for inactivity.

noomorph commented 1 year ago

Let's revisit this. If this has been resolved, maybe we should add something to documentation.