Testing patterns for Vercel AI SDK including mock providers, streaming tests, tool calling tests, snapshot testing, and test coverage strategies. Use when implementing tests, creating test suites, mocking AI providers, or when user mentions testing, mocks, test coverage, AI testing, streaming tests, or tool testing.
/plugin marketplace add vanman2024/ai-dev-marketplace/plugin install vercel-ai-sdk@ai-dev-marketplaceThis skill is limited to using the following tools:
templates/mock-provider.tsPurpose: Provide comprehensive testing templates, mock providers, and testing strategies for Vercel AI SDK applications.
Activation Triggers:
Key Resources:
templates/mock-provider.ts - Mock language model implementationtemplates/streaming-test.ts - Test streaming responsestemplates/tool-calling-test.ts - Test tool executiontemplates/snapshot-test.ts - Snapshot testing for outputsscripts/generate-test-suite.sh - Generate test scaffoldsscripts/run-coverage.sh - Run tests with coverageexamples/ - Complete test suites for different featuresTemplate: templates/mock-provider.ts
import { createMockLanguageModelV1 } from 'ai/test'
const mockProvider = createMockLanguageModelV1({
doGenerate: async ({ prompt, mode }) => ({
text: 'Mocked response'
finishReason: 'stop'
usage: { promptTokens: 10, completionTokens: 20 }
})
doStream: async function* ({ prompt, mode }) {
yield { type: 'text-delta', textDelta: 'Mocked ' }
yield { type: 'text-delta', textDelta: 'streaming ' }
yield { type: 'text-delta', textDelta: 'response' }
yield {
type: 'finish'
finishReason: 'stop'
usage: { promptTokens: 10, completionTokens: 20 }
}
}
})
Test AI functions without real API calls
Test with real providers in CI (with rate limits)
Ensure consistent outputs over time
Test complete user flows with mocks
Templates:
mock-provider.ts - Complete mock implementationstreaming-test.ts - Streaming test patternstool-calling-test.ts - Tool execution testssnapshot-test.ts - Snapshot testing setupScripts:
generate-test-suite.sh - Scaffold testsrun-coverage.sh - Run with coverageExamples:
complete-test-suite.test.ts - Full test suite exampleTesting Frameworks: Vitest, Jest, Node Test Runner SDK Version: Vercel AI SDK 5+ Coverage Tool: c8, nyc, or built-in coverage
Best Practice: Use mock providers for fast, reliable tests
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.