Testing
@witqq/agent-sdk/testing
Section titled “@witqq/agent-sdk/testing”@witqq/agent-sdk/testing
Test utilities for consumers of the agent-sdk. Provides mock factories for IAgentService, IChatRuntime, and IChatClient.
Interfaces
Section titled “Interfaces”MockAgentServiceOptions
Section titled “MockAgentServiceOptions”Defined in: testing/mock-agent-service.ts:22
Options for createMockAgentService.
Properties
Section titled “Properties”mockLLMBackend?
Section titled “mockLLMBackend?”
optionalmockLLMBackend:MockLLMBackendOptions
Defined in: testing/mock-agent-service.ts:36
Opt-in: delegate to Mock LLM backend for richer simulation. When provided, createAgent() returns a full MockLLMAgent that participates in the BaseAgent lifecycle (retry, heartbeat, middleware, usage enrichment).
models?
Section titled “models?”
optionalmodels:ModelInfo[]
Defined in: testing/mock-agent-service.ts:26
Models to return from listModels().
optionalname:string
Defined in: testing/mock-agent-service.ts:24
Service name. Default: “mock”.
onRun()?
Section titled “onRun()?”
optionalonRun: (prompt,options?) =>Promise<AgentResult<void>>
Defined in: testing/mock-agent-service.ts:30
Custom run handler. Default: returns “Mock response”.
Parameters
Section titled “Parameters”prompt
Section titled “prompt”options?
Section titled “options?”Returns
Section titled “Returns”Promise<AgentResult<void>>
onStream()?
Section titled “onStream()?”
optionalonStream: (prompt,options?) =>AsyncIterable<AgentEvent>
Defined in: testing/mock-agent-service.ts:32
Custom stream handler. Default: yields text_delta + result events.
Parameters
Section titled “Parameters”prompt
Section titled “prompt”options?
Section titled “options?”Returns
Section titled “Returns”AsyncIterable<AgentEvent>
validationResult?
Section titled “validationResult?”
optionalvalidationResult:ValidationResult
Defined in: testing/mock-agent-service.ts:28
Custom validation result. Default: { valid: true, errors: [] }.
MockChatClientOptions
Section titled “MockChatClientOptions”Defined in: testing/mock-chat-client.ts:14
Options for createMockChatClient.
Properties
Section titled “Properties”models?
Section titled “models?”
optionalmodels:ModelInfo[]
Defined in: testing/mock-chat-client.ts:18
Models to return from listModels().
onSend()?
Section titled “onSend()?”
optionalonSend: (sessionId,message,options?) =>AsyncIterable<ChatEvent>
Defined in: testing/mock-chat-client.ts:22
Custom send handler.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”message
Section titled “message”string
options?
Section titled “options?”Returns
Section titled “Returns”AsyncIterable<ChatEvent>
providers?
Section titled “providers?”
optionalproviders:ProviderConfig[]
Defined in: testing/mock-chat-client.ts:20
Providers to return from listProviders().
sessions?
Section titled “sessions?”
optionalsessions:ChatSession<Record<string,unknown>>[]
Defined in: testing/mock-chat-client.ts:16
Pre-seeded sessions.
MockMessageOptions
Section titled “MockMessageOptions”Defined in: testing/mock-data.ts:18
Options for createMockMessage.
Properties
Section titled “Properties”
optionalid:string
Defined in: testing/mock-data.ts:19
metadata?
Section titled “metadata?”
optionalmetadata:Record<string,unknown>
Defined in: testing/mock-data.ts:24
parts?
Section titled “parts?”
optionalparts:MessagePart[]
Defined in: testing/mock-data.ts:22
optionalrole:"user"|"assistant"|"system"
Defined in: testing/mock-data.ts:20
status?
Section titled “status?”
optionalstatus:"error"|"streaming"|"pending"|"complete"
Defined in: testing/mock-data.ts:23
optionaltext:string
Defined in: testing/mock-data.ts:21
MockRuntimeOptions
Section titled “MockRuntimeOptions”Defined in: testing/mock-runtime.ts:14
Options for createMockRuntime.
Properties
Section titled “Properties”defaultBackend?
Section titled “defaultBackend?”
optionaldefaultBackend:string
Defined in: testing/mock-runtime.ts:16
Default backend name. Default: “mock”.
defaultModel?
Section titled “defaultModel?”
optionaldefaultModel:string
Defined in: testing/mock-runtime.ts:18
Default model.
models?
Section titled “models?”
optionalmodels:ModelInfo[]
Defined in: testing/mock-runtime.ts:22
Models to return from listModels().
onSend()?
Section titled “onSend()?”
optionalonSend: (sessionId,message,options?) =>AsyncIterable<ChatEvent>
Defined in: testing/mock-runtime.ts:24
Custom send handler. When not provided, yields a single text_delta + done event.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”message
Section titled “message”string
options?
Section titled “options?”Returns
Section titled “Returns”AsyncIterable<ChatEvent>
sessions?
Section titled “sessions?”
optionalsessions:ChatSession<Record<string,unknown>>[]
Defined in: testing/mock-runtime.ts:20
Pre-seeded sessions.
MockSessionOptions
Section titled “MockSessionOptions”Defined in: testing/mock-data.ts:8
Options for createMockSession.
Properties
Section titled “Properties”config?
Section titled “config?”
optionalconfig:Partial<ChatSessionConfig>
Defined in: testing/mock-data.ts:12
optionalid:string
Defined in: testing/mock-data.ts:9
messages?
Section titled “messages?”
optionalmessages:ChatMessage<unknown>[]
Defined in: testing/mock-data.ts:11
metadata?
Section titled “metadata?”
optionalmetadata:Record<string,unknown>
Defined in: testing/mock-data.ts:13
status?
Section titled “status?”
optionalstatus:"active"
Defined in: testing/mock-data.ts:14
title?
Section titled “title?”
optionaltitle:string
Defined in: testing/mock-data.ts:10
Functions
Section titled “Functions”createMockAgentService()
Section titled “createMockAgentService()”createMockAgentService(
options?):IAgentService
Defined in: testing/mock-agent-service.ts:125
Create a mock IAgentService for testing agent-level code.
const service = createMockAgentService({ name: "test" });const agent = service.createAgent({ model: "gpt-5-mini" });const result = await agent.run("Hello");For richer simulation with full BaseAgent lifecycle, pass mockLLMBackend:
const service = createMockAgentService({ mockLLMBackend: { mode: { type: "echo" }, latency: { type: "fixed", ms: 50 } },});Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”createMockChatClient()
Section titled “createMockChatClient()”createMockChatClient(
options?):IChatClient
Defined in: testing/mock-chat-client.ts:33
Create a mock IChatClient for testing React hooks that talk to RemoteChatClient.
const client = createMockChatClient({ providers: [{ id: "p1", backend: "copilot", model: "gpt-5-mini", label: "GPT Mini", createdAt: "" }] });const providers = await client.listProviders();Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”createMockMessage()
Section titled “createMockMessage()”createMockMessage(
options?):ChatMessage
Defined in: testing/mock-data.ts:64
Create a mock ChatMessage for testing.
const msg = createMockMessage({ role: "user", text: "Hello" });Parameters
Section titled “Parameters”options?
Section titled “options?”MockMessageOptions = {}
Returns
Section titled “Returns”createMockRuntime()
Section titled “createMockRuntime()”createMockRuntime(
options?):IChatRuntime
Defined in: testing/mock-runtime.ts:35
Create a mock IChatRuntime for testing chat UI hooks and components.
const runtime = createMockRuntime({ defaultModel: "gpt-5-mini" });const session = await runtime.createSession({});Parameters
Section titled “Parameters”options?
Section titled “options?”MockRuntimeOptions = {}
Returns
Section titled “Returns”createMockSession()
Section titled “createMockSession()”createMockSession(
options?):ChatSession
Defined in: testing/mock-data.ts:34
Create a mock ChatSession for testing.
const session = createMockSession({ title: "Test chat" });Parameters
Section titled “Parameters”options?
Section titled “options?”MockSessionOptions = {}