Skip to content

testAgent

testAgent(agent, opts): Promise<TestResult>

Declarative test helper for Agent Express agents.

Supports single-turn (string input) and multi-turn (string[] input). For multi-turn, creates a session and runs each input as a turn.

Agent

The Agent instance to test

TestOptions

Input and optional assertions

Promise<TestResult>

TestResult with pass/fail and details

// Single turn
const result = await testAgent(agent, {
input: "Hello",
expect: { outputContains: "Hi" },
})
// Multi-turn
const result = await testAgent(agent, {
input: ["Hello", "What did I say?"],
expect: { outputContains: "Hello" },
})