ai-sdk-testing

Mock Vercel AI SDK model calls for deterministic unit and integration tests.

2|Updated Feb 23, 2026
One-click install
npx skills add https://github.com/jonmumm/skills --skill ai-sdk-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-sdk-testing
Source: https://github.com/jonmumm/skills/tree/main/ai-sdk-testing
Command: npx skills add https://github.com/jonmumm/skills --skill ai-sdk-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enables writing deterministic, fast tests for code that uses the Vercel AI SDK. LLM calls are slow, nondeterministic, and expensive — never call real providers in tests. Instead, use the SDK's built-in mock providers (ai/test) to control outputs exactly, and assert on the behavior of your code around those outputs.

Core Features & Use Cases

  • Deterministic mocks for language and embedding models (MockLanguageModelV3, MockEmbeddingModelV3) and utilities like mockId and mockValues.
  • Test generation, streaming, and structured output parsing without real LLM calls.
  • Integrations for testing in cloud workers, nightshift/ralph-tdd/swarm loops and UI streaming endpoints using simulateReadableStream.

Quick Start

Use the ai-sdk-testing skill to create a deterministic test for a module that consumes ai.generateText and ai.streamText, asserting outputs without contacting real providers.

Frequently Asked Questions about ai-sdk-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write deterministic unit tests for code using the Vercel AI SDK?

Write deterministic Vercel AI SDK tests by replacing real LLM calls with mock providers from the ai/test module, ensuring fast and reproducible test execution without network latency or API costs.

Can I mock streaming responses when testing Vercel AI SDK streamText functions?

Yes, you can mock streaming responses using simulateReadableStream to test streamText code paths deterministically, verifying token delivery and UI streaming endpoint behavior without contacting real LLM providers.

Does the Vercel AI SDK support testing structured output parsing without real API calls?

Yes, testing structured output parsing is supported without real API calls by utilizing MockLanguageModelV3 to control and inject exact mock outputs, enabling deterministic assertion validation.

What is the best way to verify token usage and error handling in Vercel AI SDK tests?

Verify token usage and error handling in Vercel AI SDK tests by configuring mock models to return specific usage metrics and simulated errors, allowing precise assertions on error handling logic.

Why should I use mock models instead of real LLM providers in my AI SDK tests?

Use mock models instead of real LLM providers because real LLM calls are slow, nondeterministic, and expensive, while mocks provide exact output control for reliable and fast automated test suites.