Testing

Both Python and TypeScript SDKs ship a MockTransport for deterministic unit testing without a live server.
The SDK ships with a MockTransport that records requests and returns canned responses — no server required.

MockTransport

Set Responses

Assert Requests

Reset Between Tests

Reset global config

If you modify global config in a test, reset it between tests to avoid cross-test pollution:

Complete Test Example

Testing Streaming

Mock SSE events for testing ZabyRuntime.stream():

Best Practices

  1. Reset between tests — Create a fresh MockTransport per test in both Python and TypeScript.
  2. Assert request paths — Verify the SDK is hitting the correct API endpoint.
  3. Mock error responses — Test your error handling by returning 4xx/5xx statuses.
  4. Use async test runners — All SDK methods are async. Mark Python tests with @pytest.mark.asyncio; use async/await in Vitest for TypeScript.