A perfect happy path is not enough to test a client well. Real APIs rate-limit, fail, and slow down, and your app needs to cope. So Understudy can misbehave on purpose.
Fault rules
A simulation can carry fault rules. When an enabled rule matches a request, the runtime returns the rule's response instead of handling the request normally. You set them up in the editor's Faults tab, with no code.
A rule has:
- A match: an HTTP method, or any, and a path, or
*for any path. - A response: a status code, optional headers like
Retry-After: 2, and an optional JSON body like{ "error": "rate limited" }. - A delay: optional latency before responding. A rule with a delay but no status is latency-only, so the response is slow but otherwise normal, for testing timeouts.
Deterministic by design
Faults fire predictably, not at random. The same setup behaves the same way every run, so a test that relies on a 429 stays stable instead of flaking.