Here is what I do: I don't use the API (in my case it's React Native app and @react-native-community/netinfo
package) directly to check if it's offline or not. I use a context to check and provide the connection status. The context also provides a function to toggle offline status. It's now easier to test the offline mode and I have full functional debugging feature.