Skip to content

Commit 23f3f45

Browse files
committed
apply some of copilot's suggestions
1 parent a0b56a3 commit 23f3f45

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

docs/mocks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Failure behavior (always strict)
2121
- Invalid fixtures (including empty `{}` when the schema defines properties) respond 500.
2222

2323
Types
24-
- Fixtures default to strict types. Generated modules import response types from `@api/types.gen` and use a `satisfies` clause to ensure compatibility.
24+
- Fixtures use strict types via the `AutoAPIMock` wrapper. Generated modules import response types from `@api/types.gen` and pass them as generic parameters to `AutoAPIMock<T>` for type safety.
2525
- Make sure `tsconfig.json` includes: `"paths": { "@api/*": ["./src/generated/*"] }`.
2626

2727
## Test-Scoped Overrides with AutoAPIMock
@@ -146,8 +146,8 @@ describe("error handling", () => {
146146
// Start with all APIs returning errors
147147
activateMockScenario(MockScenarios.ServerError);
148148

149-
// Then customize specific endpoints to succeed
150-
mockedGetRegistryV01Servers.override((data) => data);
149+
// Then reset specific endpoints to use their default response
150+
mockedGetRegistryV01Servers.reset();
151151

152152
// Now only other endpoints return errors, servers endpoint works
153153
render(<Dashboard />);

src/mocks/mockTemplate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export function deriveMockName(responseTypeName: string): string {
1818
/**
1919
* Renders a TypeScript module for a generated mock fixture.
2020
* When a response type name is provided, includes a type import
21-
* from '@api/types.gen' and a `satisfies` clause for type safety.
22-
* The fixture is wrapped in AutoAPIMock for test-scoped overrides.
21+
* from '@api/types.gen' and wraps the fixture in `AutoAPIMock<T>`
22+
* for type-safe test overrides.
2323
*/
2424
export function buildMockModule(payload: unknown, opType?: string): string {
2525
const typeName = opType?.trim();

0 commit comments

Comments
 (0)