Returns a StateAdapter backed by in-memory Maps — subscriptions, locks, KV, lists, and queues all work end-to-end. Includes a cache: Map<string, unknown> for direct inspection.
createMockChatInstance(options?)
Returns a ChatInstance with every process* handler as vi.fn(). Useful for adapter authors verifying their adapter dispatches incoming events through the right hook.
const state = createMockState();const chat = createMockChatInstance({ state });await myAdapter.handleWebhook(req); // your adapter under testexpect(chat.processMessage).toHaveBeenCalledOnce();
createTestMessage(id, text, overrides?)
Builds a Message with parsed markdown AST already wired up.
mockLogger / createMockLogger()
mockLogger is a shared Logger for tests that don't care about isolation. createMockLogger() returns a fresh one per call.
Matchers
Vitest custom matchers covering the most common Chat SDK assertions.
Text-pattern matchers (toHavePosted, toHaveEdited, toHavePostedToChannel) extract a comparable string from AdapterPostableMessage — handling plain strings, PostableMarkdown.markdown, PostableRaw.raw, and PostableCard.fallbackText. AST-shaped messages (PostableAst) and cards without fallbackText aren't text-matchable; assert without textPattern and inspect mock.calls directly for deeper checks.
Audience
Bot authors — drive simulated events through your handlers, assert on outbound calls.
Adapter authors — verify your Adapter implementation routes webhooks through the right ChatInstance.process* hook with the right normalized payload.
Adapter-specific helpers (e.g. signed Slack webhook builders, Teams claim builders) live in each adapter's own /testing subpath, not in this kit.
AI Coding Agents
If you use an AI coding agent such as OpenAI Codex, Claude Code, or Cursor, install the Chat SDK skill so it knows the SDK APIs, adapter patterns, and project conventions before writing code.
npx skills add vercel/chat
The skill references bundled documentation in node_modules/chat/docs, plus adapter guides and starter templates in the published package.
You can also install the Vercel Plugin for a broader agent toolkit — it includes the Chat SDK skill alongside specialist agents, agent slash commands, and more:
npx plugins add vercel/vercel-plugin
The plugin is optional; the skill alone is enough to build with Chat SDK.