-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How does one go about testing an offline scenario? #1501
Comments
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 |
@JanithaR, it is a bit tricky for iOS, AFAIC. So I don't see ways it can be done in a straightforward fashion with a uniform API. While for Android, the way to do is rather quick: https://stackoverflow.com/questions/10506591/turning-airplane-mode-on-via-adb But for iOS, the responses are less optimistic: https://stackoverflow.com/questions/4808433/is-it-possible-to-disable-the-network-in-ios-simulator |
Oh no, not the tinfoil solution! I cracked up when I saw that. xD The app I'm working on is an offline-first app. So there are so many things that I must ensure that behaves as per specifications when the device is offline. And that takes way too much of my time per release. I'm at the moment thinking of introducing a toggle button in the UI of all root level components which is linked to the same boolean I use to keep track of the actual state of the connection in the 'dev' builds so that I could then use Detox to toggle that. |
We are also looking for a way to test this. And it's weird that the bot closed this issue. I see this ticket as a feature request because detox doesn't contain this functionality yet. |
Guys, please take these discussions to Stack Overflow so they are much more visible. There is a reason why there is a bit closing these issues. |
As for a feature request, I’m not sure there is anything to do on iOS. The network stack is shared with the underlying Mac network stack. So I fear a feature request will help in this case. PRs are welcome 🙂 |
I beg to differ. StackOverflow is helpful for sure but my last couple of questions has gone unanswered for so long, experimenting on things by myself proved to be way quicker. I bet taken 10 people from here vs StackOverflow, chances are that more people here would be interested in this because they have, is or will run into this. With that aside, I wasn't exactly asking for a feature request but was hoping that this issue would lead up to a discussion that would end up in a new page being added to the documentation about what strategies one could utilize to test these scenarios. Because this was certainly one of the first things I looked for when I wanted to use Detox and I'm sure thousands of us who have used Detox have come up with clever alternatives. The scenarios I want to test are mainly 2 types. UI updates and application behaviour on failed API requests. I know it's not doable on iOS simulator and on doable on Android emulators through the command line. But what if we could unify the behaviour for both platforms through,
I don't know how practical these are but I have a gut feeling that these two approaches, which may not be ideal, would at least help us cover some percentage of the offline tests. |
Fbsimctl is not used anymore. And it can’t provide you with what you want. If you really want offline mode, pull the cable out of your Mac. The solution here is simple. Use mocking. It’s well documented, and you can notify your code that it’s offline when it’s really not. This is something you can implement right now and no features are needed for it in Detox. Also allow me to say that your comment is out of line. The reason we blocked help questions here is because it clutters our tracker. This is the main reason we push to Stack Overflow. We just don’t have the man power to support people. The bot explained this when closing the issue, yet you continued. Had you asked in Stack Overflow and posted your question here, you would have gotten an answer from @noomorph and/or me there. Further discussion of our Stack Overflow policy are to be had on the bots issue that is linked in the bot comment. |
I did my fair bit of Googling and others but couldn't exactly find a reliable suggestion other than
"You have to do it manually" for this but I feel like this is a very common use case and one that must be taken into account when automating e2e tests.
A typical scenario would be, there's a button which would toggle its enabled state based on the device having an active internet connection or not.
The text was updated successfully, but these errors were encountered: