agentsclimarketplace

Msw

Skill a5c-ai/babysitter/library/specializations/web-development/skills/msw

Mock Service Worker API mocking, request handlers, and integration testing.From its SKILL.md

Install
npx -y skills add a5c-ai/babysitter --skill msw

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.5 KB, 267 tokens by cl100k_base, as published. Nobody here has run it

MSW Skill

Expert assistance for API mocking with Mock Service Worker.

Capabilities

  • Create request handlers
  • Mock REST and GraphQL APIs
  • Handle network errors
  • Integrate with tests
  • Use in development

Handlers

import { http, HttpResponse } from 'msw';

export const handlers = [
  http.get('/api/users', () => {
    return HttpResponse.json([
      { id: '1', name: 'John' },
      { id: '2', name: 'Jane' },
    ]);
  }),

  http.post('/api/users', async ({ request }) => {
    const body = await request.json();
    return HttpResponse.json({ id: '3', ...body }, { status: 201 });
  }),

  http.get('/api/users/:id', ({ params }) => {
    return HttpResponse.json({ id: params.id, name: 'John' });
  }),
];

Test Integration

import { setupServer } from 'msw/node';
import { handlers } from './handlers';

const server = setupServer(...handlers);

beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());

Target Processes

  • api-mocking
  • integration-testing
  • frontend-development

What ships with it: 1 file

362 B alongside SKILL.md

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.