Relmock Guide

Use your API

Network, latency and time

Real backends are slow, fail and change while you look. Relmock can do the same on purpose, so you can test spinners, retries, error screens and data that moves on.

Network modes

Settings, Network: the Healthy, Flaky, Offline and Corrupted modes, and an added latency field

Change the mode in Settings › Network, or from Network in the status bar at the bottom of every project page. It applies to every request to the project.

ModeWhat your app gets
HealthyNormal answers, no added errors.
Flaky200 ms to 2.5 s of delay on every call; 10% answer 500, 5% 504 and 5% 429 with Retry-After.
OfflineEvery call answers 503 Service Unavailable at once.
CorruptedRandom fields are set to null or left out, with an X-Payload-Corrupted header. The id is never touched.
Tip
Remember to switch back to Healthy. The status bar shows the current mode on every page.

Added latency

Set Added latency in the same place, from 0 to 10,000 ms, to make every answer wait that long. Good for checking that loading states appear and don't flicker.

One request at a time

Two query parameters work on any route, without changing settings:

# wait 1.5 seconds before answering
GET /orders?_delay=1500

# answer 503 without running the request
POST /orders?_status=503

_delay replaces the project's added latency for that call. With an error status, _status doesn't run the request, so nothing is written.

The mock clock

Fields with changes over time move on as time passes: an order goes from pending to paid after 2 minutes. To test it without waiting, move the project's clock forward from Clock in the status bar, or from your tests:

POST /_time/advance?minutes=30   # also seconds, hours, days
GET  /_time                      # the mock's current time
POST /_time/reset                # back to real time

Defaults of now on new records use the mock clock too.