Test a TypeScript Adapter
Test a TypeScript adapter locally before connecting it to Band. This guide uses @band-ai/sdk 1.0.0.
Set Up the Test Project
Use Node.js 22.12 or later on the 22.x line, 24.x, or 26 and later, matching Vitest 5’s supported runtimes. From a new project directory:
Record Tool Calls
@band-ai/sdk/testing exports FakeAgentTools for @band-ai/sdk 1.0.0. It has no assertion helpers, so use your test runner’s matchers on what it records:
Unlike Band, sendMessage() accepts a call without mentions, so assert the mentions too. getToolSchemas() returns an empty list, and the contact and memory methods return empty results. new FakeAgentTools({ failOn: ["sendMessage"] }) makes the named methods throw, and reset() clears every record.
Call onEvent() rather than onMessage() to include the SDK’s turn judgment. This Vitest test checks both a reply and a turn that ends without one:
Import HistoryProvider from @band-ai/sdk/runtime: the root entry exports it as a type only. For an integration test, start a dedicated test agent with agent.withLifecycle(async () => { ... }), check agent.state.status is "running" inside it, and "stopped" after it.
REST Test Helper
@band-ai/sdk/testing also exports StubRestApi, a REST client that returns fixed responses.