Agent tester utility for testing AI agents with deterministic responses.
import { AgentTester } from '@stratix/testing';describe('MyAgent', () => { let tester: AgentTester; beforeEach(() => { tester = new AgentTester(); }); it('should process input correctly', async () => { const agent = new MyAgent(...); tester.setMockResponse({ content: '{"result": "success"}', usage: { promptTokens: 10, completionTokens: 20, totalTokens: 30 } }); const result = await tester.test(agent, input); expect(result.passed).toBe(true); expect(result.result.isSuccess()).toBe(true); });}); Copy
import { AgentTester } from '@stratix/testing';describe('MyAgent', () => { let tester: AgentTester; beforeEach(() => { tester = new AgentTester(); }); it('should process input correctly', async () => { const agent = new MyAgent(...); tester.setMockResponse({ content: '{"result": "success"}', usage: { promptTokens: 10, completionTokens: 20, totalTokens: 30 } }); const result = await tester.test(agent, input); expect(result.passed).toBe(true); expect(result.result.isSuccess()).toBe(true); });});
Gets the mock LLM provider
Sets a single mock response
Sets multiple mock responses
Tests an agent with the given input
Optional
Asserts that the result is successful
Asserts that the result is a failure
Asserts that execution time is within limits
Asserts that the mock provider was called N times
Resets the tester state
Agent tester utility for testing AI agents with deterministic responses.
Example