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…
REQUIRED and PRIMARY testing approach for packages/playground and packages/playground-ui. Triggers on: adding or modifying hooks, pages, route components, data-fetching code, React Query interactions, or any test work in these packages. Generates Vitest tests that drive the real
Claude Code
$ npx -y skills add mastra-ai/mastra --skill playground-msw-tests --agent claude-code
Codex
$ npx skills add mastra-ai/mastra --skill playground-msw-tests -a codex -y
Cursor
$ npx skills add mastra-ai/mastra --skill playground-msw-tests -a cursor -y
Gemini CLI
$ npx skills add mastra-ai/mastra --skill playground-msw-tests -a gemini-cli -y
GitHub Copilot
$ npx skills add mastra-ai/mastra --skill playground-msw-tests -a github-copilot -y
OpenCode
$ npx skills add mastra-ai/mastra --skill playground-msw-tests -a opencode -y
Windsurf
$ npx skills add mastra-ai/mastra --skill playground-msw-tests -a windsurf -y
name: playground-msw-tests description: > REQUIRED and PRIMARY testing approach for packages/playground and packages/playground-ui. Triggers on: adding or modifying hooks, pages, route components, data-fetching code, React Query interactions, or any test work in these packages. Generates Vitest tests that drive the real @mastra/client-js + React Query stack through MSW handlers and typed fixtures derived from @mastra/client-js response types. This is the #1 way to test the playground packages — ABOVE Playwright E2E. Use Playwright only for cross-page user journeys that MSW cannot model.
**Drive the real transport, mock the network.**
Tests in `packages/playground` and `packages/playground-ui` MUST be written as Vitest tests that exercise the real `@mastra/client-js` SDK, the real React Query cache, and the real component/hook code paths. The only seam we mock is the network boundary, via [MSW](https://mswjs.io/).
This catches contract drift between the playground and `@mastra/client-js` at typecheck time and at test time — something `vi.mock('@/hooks/...')` style tests cannot do.
When you write or refactor a test for these packages, choose in this order:
1. **MSW + typed client-js fixtures (THIS SKILL)** — for hooks, pages, routes, data-fetching, gating, redirect logic, query/mutation flows, error paths. 2. **Playwright E2E** (`e2e-tests-studio` skill) — only for genuine cross-page user journeys, real browser concerns (focus/keyboard/viewport), or anything that requires a real running Mastra server. 3. **Pure unit tests** — only for self-contained utilities/services with no network, no React Query, no router involvement.
If the same behavior can be covered by both #1 and #2, **prefer #1**. MSW tests are faster, deterministic, run in CI without browsers, and assert the real wire contract.
cache, gating and transport bugs.
branch logic, generated shapes, or calculations without asserting a real behavior or regression.
usually just tests that the implementation string exists. Prefer no test over a className duplication test; use computed style, user-visible behavior, or a browser/Storybook check unless the class string itself is the public API.
these drift silently from the real SDK.
responses, request payloads, hook inputs, or component event inputs.
`@mastra/client-js` response. If a field is optional, include it as optional in the fixture, don't omit the type.
(e.g. `ListStoredAgentsResponse`, `GetAgentResponse`, `BuilderSettingsResponse`, `GetToolResponse`, `GetWorkflowResponse`, `ListStoredSkillsResponse`).
or Testing Library APIs for MSW payloads, request payloads, hook inputs, and component events.
between tests via the global `afterEach`.
so the real client SDK is the transport.
hit (great for testing `enabled: ...` gating without mocking hooks).
// @vitest-environment jsdom
import { MastraReactProvider } from '@mastra/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { cleanup, render, screen } from '@testing-library/react';
import { http, HttpResponse } from 'msw';
import { MemoryRouter } from 'react-router';
import { afterEach, describe, expect, it } from 'vitest';
import { server } from '@/test/msw-server';
import { Subject } from '../subject';
import { happyPathResponse } from './fixtures/subject';
const BASE_URL = 'http://localhost:4111';
const renderSubject = () => {
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
return render(
<MastraReactProvider baseUrl={BASE_URL}>
<QueryClientProvider client={queryClient}>
<MemoryRouter>
<Subject />
</MemoryRouter>
</QueryClientProvider>
</MastraReactProvider>,
);
};
afterEach(() => cleanup());
describe('Subject', () => {
it('renders the happy path', async () => {
server.use(http.get(`${BASE_URL}/api/agents`, () => HttpResponse.json(happyPathResponse)));
renderSubject();
expect(await screen.findByText('Expected behavior')).not.toBeNull();
});
});// packages/playground/src/.../__tests__/fixtures/subject.ts
import type { ListStoredAgentsResponse } from '@mastra/client-js';
export const emptyStoredAgents: ListStoredAgentsResponse = {
agents: [],
total: 0,
page: 1,
perPage: 50,
hasMore: false,
};
export const oneDraftAgent: ListStoredAgentsResponse = {
...emptyStoredAgents,
agents: [
{
id: 'agent-1',
name: 'Draft Agent',
instructions: '',
model: { provider: 'openai', name: 'gpt-4o-mini' },
status: 'draft',
// ...other required fields from StoredAgentResponse
},
],
total: 1,
};**If a required field on the SDK response type is missing from your fixture, that's a real test failure — fix the fixture, never `as any` it.** The same applies to hook inputs, compo
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.