Examples
Using a predefined condition:
Custom conditions:
Offline mode (no connectivity):
When to use
- Testing how your app behaves when loading is slow — spinners, timeouts, retry logic.
- Verifying your app shows the right error messages when connectivity is poor or lost.
- Testing video or audio streaming features that adapt quality based on available bandwidth (adaptive bitrate streaming).
- Reproducing issues customers have reported on slow or unreliable connections.
- Making sure your app degrades gracefully for users on 2G or 3G networks.
Notes
- Before calling
device.simulateNetworkCondition(), you must call device.routeTraffic(); otherwise, you will get an error.
- Always call cleanup functions in reverse order: restore network conditions first, then stop routing.
- Bandwidth limiting applies to TCP traffic only.
- Latency, jitter, and packet loss apply to all traffic (TCP and UDP).
NETWORK_OFFLINE simulates no connectivity by dropping all packets. Requests will time out rather than fail immediately — this may behave differently from a true offline state on some devices.
Full sample test
Last modified on May 13, 2026