Skip to content

Commit 902d6a4

Browse files
committed
.
1 parent ba86ebf commit 902d6a4

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

docs/mocks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MSW Auto-Mocker
22

33
- Handlers: `src/mocks/handlers.ts` combines non-schema mocks and auto-generated mocks.
4-
- Non-schema mocks: add hand-written handlers in `src/mocks/customHandlers/index.ts`. These run before auto-generated handlers so they can replace or extend behavior when needed.
4+
- Non-schema mocks: add hand-written handlers in `src/mocks/customHandlers/index.ts`. These take precedence over schema-based mocks.
55
- Auto-generated: `src/mocks/mocker.ts` reads `swagger.json` and creates fixtures under `src/mocks/fixtures` on first run.
66
- Validation: Loaded fixtures are validated with Ajv; errors log to console.
77

src/mocks/customHandlers/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import type { RequestHandler } from "msw";
22

33
// Add non-schema, hand-written mocks here.
4-
// These are composed before the auto-generated handlers (handlers.ts),
5-
// so they can replace or extend behavior where needed.
4+
// These take precedence over the schema-based mocks.
65
export const customHandlers: RequestHandler[] = [
76
// Example override: customize one endpoint's payload
87
// http.get("*/registry/v0.1/servers", () =>

src/mocks/fixtures/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Fixtures are auto-generated on first run by the MSW Auto-Mocker.
55
- You can edit these files to tailor responses for tests or local dev.
66

77
Notes
8-
- Non-schema mocks in `src/mocks/customHandlers` run before auto-generated ones.
8+
- Non-schema mocks in `src/mocks/customHandlers` take precedence over schema-based mocks.
99
- To re-generate a fixture, delete the file; it will be recreated on next request.
1010
- If your project exposes OpenAPI response types via `@api/types.gen`, you can
1111
enable type enforcement by setting `USE_TYPES_FOR_FIXTURES = true` in

0 commit comments

Comments
 (0)