← ClaudeAtlas

mocking-inprocess-typescriptlisted

Use when the mocking-strategy-roster resolved (inprocess, TypeScript) — the override mocking strategy that replaces a downstream HTTP API with an in-process double (MSW answering at the network layer, or a hand-written gateway handed to the feature) in a Vitest integration test, instead of a Microcks container. Emits mock wiring only; the business TDD cycle stays with the software-engineer lead.
SebastienDegodez/skraft-plugin · ★ 14 · Testing & QA · score 70
Install: claude install-skill SebastienDegodez/skraft-plugin
# Mocking — In-process x TypeScript adapter (override) Replaces a downstream HTTP API the code under test calls with an in-process double in a Vitest integration test. Selected when the operator overrides the Microcks default. Loaded ONLY when `mocking-strategy-roster` resolved `(inprocess, TypeScript)`. When no library is named, the table below is ordered by priority: take the first row that fits and whose package is already a devDependency; otherwise the first row that fits. **Boundary:** mock wiring + integration-test scaffold only. No business TDD, no provider contract verification. ## Libraries (table order = priority, top = highest) | Priority | Library | Fits | Double | |---|---|---|---| | 1 | msw | the gateway calls through `fetch` (or a client built on it) | `setupServer(http.get(...))` answering at the network layer | | 2 | fake | any gateway behind an application interface | a hand-written class implementing the gateway interface | ## Recipe — MSW (gateway test) ```ts // tests/integration/{feature}/infrastructure/Http{Feature}Gateway.test.ts // @vitest-environment node import { http, HttpResponse } from 'msw' import { setupServer } from 'msw/node' import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest' import { HttpRatesGateway } from '../../../../src/expenses/infrastructure/HttpRatesGateway' const api = 'http://rates.test' const server = setupServer(http.get(`${api}/rates/USD`, () => HttpResponse.json({ rate: 1.08 }))) beforeAll(()