builder-smoke-test
Smoke test the Agent Builder feature branch end-to-end against a hermetic project scaffolded by the skill (linked to the current…
Use when writing or debugging integration tests for error processors in packages/core/src/processors/. Covers the MockLanguageModelV2 pattern for simulating API errors and verifying retry behavior, plus the build prerequisites for focused vitest runs.
Claude Code
$ npx -y skills add mastra-ai/mastra --skill testing-core-processors --agent claude-code
Codex
$ npx skills add mastra-ai/mastra --skill testing-core-processors -a codex -y
Cursor
$ npx skills add mastra-ai/mastra --skill testing-core-processors -a cursor -y
Gemini CLI
$ npx skills add mastra-ai/mastra --skill testing-core-processors -a gemini-cli -y
GitHub Copilot
$ npx skills add mastra-ai/mastra --skill testing-core-processors -a github-copilot -y
OpenCode
$ npx skills add mastra-ai/mastra --skill testing-core-processors -a opencode -y
Windsurf
$ npx skills add mastra-ai/mastra --skill testing-core-processors -a windsurf -y
name: testing-core-processors description: Use when writing or debugging integration tests for error processors in packages/core/src/processors/. Covers the MockLanguageModelV2 pattern for simulating API errors and verifying retry behavior, plus the build prerequisites for focused vitest runs.
How to write integration tests for error processors in `packages/core/src/processors/`.
Use `MockLanguageModelV2` from `@internal/ai-sdk-v5/test` to simulate API errors and verify retry behavior.
import { APICallError } from '@internal/ai-sdk-v5';
import { convertArrayToReadableStream, MockLanguageModelV2 } from '@internal/ai-sdk-v5/test';
// Track calls and captured prompts
let callCount = 0;
const receivedPrompts: any[] = [];
const model = new MockLanguageModelV2({
doGenerate: async ({ prompt }) => {
callCount++;
receivedPrompts.push(JSON.parse(JSON.stringify(prompt)));
if (callCount === 1) {
throw new APICallError({
message: '...',
url: '...',
requestBodyValues: {},
statusCode: 400,
responseBody: '...',
isRetryable: false,
});
}
return {
rawCall: { rawPrompt: null, rawSettings: {} },
finishReason: 'stop',
usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 },
content: [{ type: 'text', text: 'response' }],
warnings: [],
};
},
doStream: async ({ prompt }) => {
// Same error logic as doGenerate
// IMPORTANT: Stream response must include all event types:
return {
rawCall: { rawPrompt: null, rawSettings: {} },
warnings: [],
stream: convertArrayToReadableStream([
{ type: 'stream-start', warnings: [] },
{ type: 'response-metadata', id: 'id-0', modelId: 'mock-model', timestamp: new Date(0) },
{ type: 'text-start', id: 'text-1' },
{ type: 'text-delta', id: 'text-1', delta: 'response text' },
{ type: 'text-end', id: 'text-1' },
{ type: 'finish', finishReason: 'stop', usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 } },
]),
};
},
});The stream mock format requires `stream-start`, `response-metadata`, `text-start`, `text-delta`, `text-end`, and `finish` events. Using only `text-delta` + `finish` (the minimal format) will result in empty text output because the AI SDK expects the full event sequence. See `prefill-error-recovery.test.ts` for the reference pattern.
For each error processor, write at minimum:
1. **Happy path**: Processor catches the target error, modifies messages, retries successfully
2. **Control test**: Same scenario without the processor — error propagates
3. **Selectivity test**: Processor ignores unrelated errors (e.g. rate limit 429)
When seeding conversation history for tool-related tests, pass messages as the second argument to `agent.generate()` or `agent.stream()` using the AI SDK message format:
const messages = [
{ role: 'user', content: 'Do something' },
{ role: 'assistant', content: [{ type: 'tool-call', toolCallId: 'some-id', toolName: 'myTool', args: {} }] },
{ role: 'tool', content: [{ type: 'tool-result', toolCallId: 'some-id', toolName: 'myTool', result: 'done' }] },
];
await agent.generate(messages);# Run focused processor tests npx vitest run packages/core/src/processors/my-processor.test.ts # Run all processor tests npx vitest run packages/core/src/processors/ # Full core test suite (slower) pnpm test:core
None for mock-based integration tests. For live API tests:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack. It includes everything you need to go from early prototypes to production-ready applications.
Smoke test the Agent Builder feature branch end-to-end against a hermetic project scaffolded by the skill (linked to the current…
Use early when debugging a medium or hard bug, especially when tests alone may not reveal the real runtime failure. Trigger this…
Autonomous, report-only documentation review for Mastra docs. Use when auditing changed docs against source, validating…
Convert existing docs diagram images to Mermaid, and author new Mermaid diagrams for Mastra docs. Use when replacing an…
REQUIRED when modifying any file in packages/playground-ui or packages/playground. Triggers on: React component…
Review open mastra-ai/mastra GitHub issues, identify direct @mastra/core bugs, and apply the @mastra/core label. Use when…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.