Closed compojoom closed 4 years ago
We use the issue tracker exclusively for bug reports and feature requests. This issue appears to be a general usage or support question. Instead, please ask a question on Stack Overflow with the detox
tag.
Feel free to post your Stack Overflow question here for more visility. We'll take a look at it.
For issues with Expo apps, it is most likely not an issue with Detox itself, but with the Expo runtime or with incorrect Detox setup. For support on how to use Detox with Expo, you should contact the Expo team or the Expo community.
For more information on bots in this reporsitory, read this discussion.
Posted on stackoverflow: https://stackoverflow.com/questions/58798351/better-way-to-e2e-test-toast-animations-with-detox
@LeoNatan - maybe something to think about? No idea if a better solution exist, but somehow the whole thing feels awkward . The actuall message is visible on the screen for 4s. Displaying the message takes less than few hundred miliseconds and after that the message is there. Detox does nothing because it sees a setTimeout. The app however is fully responsive in the meantime... We don't have an endless loop animation...
I'm trying to test the following Toast component:
Running this on iOS outputs a View with a Text message. My view has a testID set to "toast". To show the toast we dispatch a redux action, which in term triggers the Toast.
I have the following test that fails:
I understand that the test fails because of the automatic synchronization of detox. When we press the button we dispatch a redux action. The toast displays and a setTimeout of 4s is set. Now detox waits 4s before it tests whether the "toast"element is visible or not. When the 4s are over the element is destroyed from the view and detox cannot find it.
There are different workarounds for this. The first one would be to disableSynchronization before taping on the button and then to enable it after the toast has been displayed. this works, but the test needs 4s+ to complete. For some reason even though the sync is disabled we still wait for the setTimeout to complete, but this time we see the element.
Another option as per the docs is to disable the animation for e2e tests. I tested this and it's working, but I'm wondering if there is a better way?
In this particular case the actual animation takes few hundred ms and after that we display the view and wait for it to disapper. There is no need for detox to wait. The real users using the app also don't have to wait either.
Is there any way to make this whole thing a little more user friendly for people writing the tests :)