Overview
Polyglot supports deterministic tests at two main seams.- use fake drivers when you want to bypass HTTP and drive the runtime directly
- use
MockHttpDriverwhen you want to keep transport and provider adapter behavior in play
CanProcessDecisionRequest contract as an application-local fake or inject a
MockHttpDriver client when the TypeSafe wire adapter is under test.
FakeInferenceDriver
FakeInferenceDriver lives in packages/polyglot/tests/Support.
Use it when you want to test:
Inferencerequest execution without real HTTP- retry and event behavior around raw inference responses
- streaming assembly from queued
PartialInferenceDeltabatches
- queued
InferenceResponseobjects - queued streaming delta batches
- callback-driven sync or streaming behavior when the test needs custom logic
FakeEmbeddingsDriver
FakeEmbeddingsDriver also lives in packages/polyglot/tests/Support.
Use it when you want to test:
EmbeddingsandPendingEmbeddingsbehavior without real HTTP- memoization and runtime delegation
- event dispatch around completed embeddings responses
- queued
EmbeddingsResponseobjects - callback-driven response generation from
EmbeddingsRequest - request recording through
handleCallsandrequests
MockHttpDriver
Use MockHttpDriver when the HTTP layer still matters.
This is the right seam for:
- provider adapter tests
- request body and header assertions
- golden tests around provider-specific payload shapes
- error-path coverage that depends on real HTTP response objects
DecisionRuntime::fromConfig(..., httpClient: $httpClient) to cover the
TypeSafe request and response adapters without a live API call. See
Decision errors and testing for the full Decision
test matrix and opt-in live smoke command.
Which One To Use
Use this rule of thumb:FakeInferenceDriverfor most deterministic inference testsFakeEmbeddingsDriverfor most deterministic embeddings tests- an application-local
CanProcessDecisionRequestfake for Decision runtime behavior MockHttpDriverfor transport and provider adapter coverage