docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a helper that defines mock HTTP responses for an order API at a given base URL. Each priming method should affect the next matching request only. cleanup() removes any remaining interceptors.
/health returns status 200, JSON body {"status":"ok"}, and includes header x-mock: health. @test/orders with a JSON body including those fields to return status 201 and a JSON body containing a generated non-empty id plus the provided amount and currency. @test/orders missing the amount to fail at the request layer with that message (no HTTP status code is received). @test/orders/{id} to return status 503, a JSON body {"error":"outage"}, and a retry-after header of 120. @testexport interface OrderReplyInput {
amount: number;
currency: string;
}
export interface OrderReply extends OrderReplyInput {
id: string;
}
export interface MockOrderService {
prepareHealthCheck(): void;
queueOrderReply(payload: OrderReplyInput): void;
queueOrderError(message: string): void;
queueOutage(orderId: string): void;
cleanup(): void;
}
export function createMockOrderService(baseUrl: string): MockOrderService;Provides HTTP interception and mock responses.