mockAgent()
mockAgent() creates a runtime-neutral Agent mock with writable signals for testing @ngaf/chat components. Use it when you are testing chat UI behavior and do not need LangGraph-specific fields.
Import:
#Signature
#Options
| Option | Type | Default | Description |
|---|---|---|---|
messages | Message[] | [] | Initial runtime-neutral messages |
status | AgentStatus | 'idle' | Initial agent status |
isLoading | boolean | false | Whether the agent is currently running |
error | unknown | null | Initial error value |
toolCalls | ToolCall[] | [] | Initial tool-call list |
state | Record<string, unknown> | {} | Initial agent state |
withInterrupt | boolean | false | Include a writable interrupt signal |
withSubagents | boolean | false | Include a writable subagents signal |
history | AgentCheckpoint[] | undefined | Include history and return an AgentWithHistory-compatible mock |
#Basic Test Usage
#Controlling State
The returned mock exposes writable signals, so tests can update state directly:
#Spying on Actions
The mock records calls to core actions:
#LangGraph-Specific Tests
Use mockLangGraphAgent() from @ngaf/langgraph only when the test needs LangGraph-specific signals such as raw LangGraph messages, checkpoint state, branches, queued runs, or transport metadata.