[SOLVED] How to test app's offline behaviour?

Hello everybody,

I’m trying to debug and test the behaviour of my app, inside the Expo app, when the user is offline (I’m using redux-logger).

In order to do this I’m trying to maintain the WiFi connection and block remote connections but it seems it’s not working: NetInfo always tells I’m online.

I’m on a Windows PC and an Android phone, here are my current steps:

  1. I start the packager with exp start --offline
  2. I use a firewall app (NoRoot Firewall) to block everything other than connections to my local ip address and to amazonaws (in order for Expo app to work).

I suppose NetInfo checks the connection status at a lower level and therefore my approach doesn’t work.

What can I try instead? I need a connection with the console while offline.

Found a working solution: I went back to XDE and used Host: localhost. Now I can enable/disable connection on my phone without problems. More details here.

2 Likes

Hi, when you switched to localhost, what address did you give the expo client on your Android device to connect to?

Thanks!

Hi Frank, just connect your Android phone with your PC via USB.

Then, with your project opened, click on Device > Open on Android. The Expo app should open by itself on your phone.

If this way it doesn’t work, click Project > Open in cmd, type adb reverse tcp:19000 tcp:19000 [ENTER], then adb reverse tcp:19001 tcp:19001 [ENTER] in the command prompt, then click on Device > Open on Android. More details here.

1 Like