Overview
Instructor supports deterministic tests at three different seams.- use
FakeInferenceDriverwhen you want to drive Instructor directly with queued raw responses or streaming deltas - use
MockHttpwhen you want to keep the provider adapter and HTTP response path in play - use probe helpers when you need to assert streaming timing, call counts, or emission order
FakeInferenceDriver
FakeInferenceDriver lives in packages/instructor/tests/Support and is the main
contributor-facing fake for deterministic Instructor tests.
Use it when you want to test:
- deserialization and validation behavior
- retry logic
- stream accumulation and final response behavior
- partial and sequence handling without real HTTP or provider adapters
- queued
InferenceResponseobjects for sync execution - queued
PartialInferenceDeltabatches for streaming execution
packages/instructor.
MockHttp
MockHttp lives in packages/instructor/tests and builds an HTTP client around
MockHttpDriver.
Use it when you want to test:
- provider-specific adapter behavior
- request and response wiring that still goes through HTTP
- response payload shapes such as OpenAI or Anthropic fixtures
FakeInferenceDriver.
Streaming Probes
ProbeStreamDriver and ProbeIterator live in packages/instructor/tests/Integration/Support.
Use them when you need to assert:
- that streaming updates are emitted immediately
- how many sync versus stream reads occurred
- exact delta ordering in an integration-style test
FakeInferenceDriver. They are for observation,
not for general-purpose fixture setup.
Which One To Use
Use this rule of thumb:FakeInferenceDriverfor most deterministic Instructor behavior testsMockHttpfor adapter- and payload-level coverage- probe helpers for streaming immediacy and observation-heavy assertions