ai-test-kit

Type-safe test helpers for AI SDK apps: mock models, build content/stream parts, simulate errors, and assert UI-message behavior without real provider calls.

Current Source Snapshot

As of the 2026-07-01 registry refresh, npm reports ai-test-kit@3.0.1 as latest, 3.0.0-next.3 as next, and 2.1.1 as legacy. The latest package targets AI SDK 7 with peer dependencies on ai@^7.0.0, @ai-sdk/provider@^4.0.0, and @ai-sdk/provider-utils@^5.0.0, requires Node >=22, and exports root, language, ui, embedding, and image helper surfaces. GitHub tag v3.0.1 resolves to current HEAD 3baebe55b177e8473cf50e32ecbd4ec502e23234. Source: npm registry packument; git ls-remote, 2026-07-01

What It Solves

AI SDK tests often repeat the same boilerplate: mocking a model, constructing valid stream parts, simulating retries, pinning deterministic IDs/timestamps, and draining streams. ai-test-kit packages those helpers behind type-safe builders. Source: GitHub README, 2026-06-25

Useful surfaces:

Surface Use
ai-test-kit/language Mock LanguageModelV3; build text, reasoning, tool calls, files, sources, generate results, and stream parts
ai-test-kit/ui Build UIMessagePart, UIMessageChunk, and UIMessage fixtures for client/server UI reducers
ai-test-kit/embedding Mock embedding models and vectors
ai-test-kit/image Mock image models and image results
Streams / Iterables Build, drain, and convert ReadableStream and AsyncIterable values
Errors Create realistic API/provider errors for retries, fallback, and failure handling

Routing

Use this when working on Vercel AI SDK code and the proof needs deterministic model behavior:

  • agent tool-call tests;
  • streamText / generateText behavior;
  • UI-message reducer tests;
  • retry, fallback, abort, and error-shape tests;
  • tests that should not spend provider tokens or depend on live model variance.

Do not use it as the only proof for provider-specific wire behavior. Its README notes that it mocks the AI SDK LanguageModelV3 interface, not the HTTP/SSE wire layer. For provider-specific protocol bugs, use a fake server or provider-specific integration test. Source: GitHub README, 2026-06-25

Kevin Default

When the ai-sdk skill is loaded and production code changes an AI SDK tool loop, stream UI, retry path, or approval flow, prefer a focused deterministic test using built-in ai/test primitives or ai-test-kit before relying on manual demos. Use the smallest helper that proves the invariant.

The reviewed launch image shows the intended proof shape: build a mock language model from a plain string, construct a real tool call instead of hand-written part shapes, and simulate streamed reasoning plus answer chunks that drain through the UI message stream. That makes it a good fit for Awesome Evals implementation work where the target is deterministic AI SDK behavior rather than a full agent trajectory.


Timeline