Skip to content

Testing

@witqq/agent-sdk/testing

Test utilities for consumers of the agent-sdk. Provides mock factories for IAgentService, IChatRuntime, and IChatClient.

Defined in: testing/mock-agent-service.ts:22

Options for createMockAgentService.

optional mockLLMBackend: 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).

optional models: ModelInfo[]

Defined in: testing/mock-agent-service.ts:26

Models to return from listModels().

optional name: string

Defined in: testing/mock-agent-service.ts:24

Service name. Default: “mock”.

optional onRun: (prompt, options?) => Promise<AgentResult<void>>

Defined in: testing/mock-agent-service.ts:30

Custom run handler. Default: returns “Mock response”.

MessageContent

RunOptions

Promise<AgentResult<void>>

optional onStream: (prompt, options?) => AsyncIterable<AgentEvent>

Defined in: testing/mock-agent-service.ts:32

Custom stream handler. Default: yields text_delta + result events.

MessageContent

RunOptions

AsyncIterable<AgentEvent>

optional validationResult: ValidationResult

Defined in: testing/mock-agent-service.ts:28

Custom validation result. Default: { valid: true, errors: [] }.


Defined in: testing/mock-chat-client.ts:14

Options for createMockChatClient.

optional models: ModelInfo[]

Defined in: testing/mock-chat-client.ts:18

Models to return from listModels().

optional onSend: (sessionId, message, options?) => AsyncIterable<ChatEvent>

Defined in: testing/mock-chat-client.ts:22

Custom send handler.

ChatIdLike

string

SendMessageOptions

AsyncIterable<ChatEvent>

optional providers: ProviderConfig[]

Defined in: testing/mock-chat-client.ts:20

Providers to return from listProviders().

optional sessions: ChatSession<Record<string, unknown>>[]

Defined in: testing/mock-chat-client.ts:16

Pre-seeded sessions.


Defined in: testing/mock-data.ts:18

Options for createMockMessage.

optional id: string

Defined in: testing/mock-data.ts:19

optional metadata: Record<string, unknown>

Defined in: testing/mock-data.ts:24

optional parts: MessagePart[]

Defined in: testing/mock-data.ts:22

optional role: "user" | "assistant" | "system"

Defined in: testing/mock-data.ts:20

optional status: "error" | "streaming" | "pending" | "complete"

Defined in: testing/mock-data.ts:23

optional text: string

Defined in: testing/mock-data.ts:21


Defined in: testing/mock-runtime.ts:14

Options for createMockRuntime.

optional defaultBackend: string

Defined in: testing/mock-runtime.ts:16

Default backend name. Default: “mock”.

optional defaultModel: string

Defined in: testing/mock-runtime.ts:18

Default model.

optional models: ModelInfo[]

Defined in: testing/mock-runtime.ts:22

Models to return from listModels().

optional onSend: (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.

ChatIdLike

string

RuntimeSendOptions

AsyncIterable<ChatEvent>

optional sessions: ChatSession<Record<string, unknown>>[]

Defined in: testing/mock-runtime.ts:20

Pre-seeded sessions.


Defined in: testing/mock-data.ts:8

Options for createMockSession.

optional config: Partial<ChatSessionConfig>

Defined in: testing/mock-data.ts:12

optional id: string

Defined in: testing/mock-data.ts:9

optional messages: ChatMessage<unknown>[]

Defined in: testing/mock-data.ts:11

optional metadata: Record<string, unknown>

Defined in: testing/mock-data.ts:13

optional status: "active"

Defined in: testing/mock-data.ts:14

optional title: string

Defined in: testing/mock-data.ts:10

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 } },
});

MockAgentServiceOptions = {}

IAgentService


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();

MockChatClientOptions = {}

IChatClient


createMockMessage(options?): ChatMessage

Defined in: testing/mock-data.ts:64

Create a mock ChatMessage for testing.

const msg = createMockMessage({ role: "user", text: "Hello" });

MockMessageOptions = {}

ChatMessage


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({});

MockRuntimeOptions = {}

IChatRuntime


createMockSession(options?): ChatSession

Defined in: testing/mock-data.ts:34

Create a mock ChatSession for testing.

const session = createMockSession({ title: "Test chat" });

MockSessionOptions = {}

ChatSession