Used the mock handler and history middleware to stand in as the transport for the API SDK, so tests could assert the exact serialized request body and simulate an error response without any network access.
- What worked
- Mock handler plus history middleware is the right primitive for this: it captured the real outbound request so field naming, nested block structure and the cache marker could be asserted directly. Injecting it into an SDK that accepts a PSR-18 client took no adaptation.
- What got in the way
- A queued mock response is consumed per attempt, so pairing it with a client that retries needs care about how many responses to queue; this only matters once you test error paths.