You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/mocks.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ MSW Auto-Mocker
8
8
Usage
9
9
- Vitest: tests initialize MSW in `src/mocks/test.setup.ts`. Run `pnpm test`.
10
10
- Browser (optional): call `startWorker()` from `src/mocks/browser.ts` in your development entry point to mock requests in the browser.
11
-
- Standalone server (dev): `pnpm mock:server` starts an HTTP mock server at `http://localhost:9090` (configurable with `MOCK_PORT`). Point API requests or Next.js rewrites to this origin to develop without a live backend.
11
+
- Standalone server (dev): `pnpm mock:server` starts an HTTP mock server at `http://localhost:9090`. In dev, Next.js rewrites proxy `/registry/*`to this origin; use relative URLs like `/registry/v0.1/servers` from both client and server code.
12
12
13
13
Regeneration
14
14
- Delete a fixture file to re-generate it on next request.
- If a schema is missing or faker fails, the handler responds 500 and does not write a placeholder.
18
18
- Invalid fixtures (including empty `{}` when the schema defines properties) respond 500.
19
19
20
-
Types (optional)
21
-
- If you expose OpenAPI response types under `@api/types.gen`, set `USE_TYPES_FOR_FIXTURES = true` in `src/mocks/mocker.ts` to add a `satisfies` clause in generated fixtures.
20
+
Types
21
+
- Fixtures default to strict types. Generated modules import response types from `@api/types.gen` and use a `satisfies` clause to ensure compatibility.
22
+
- Make sure `tsconfig.json` includes: `"paths": { "@api/*": ["./src/generated/*"] }`.
0 commit comments