docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
A small helper for managing HTTP mocks that ensures planned interactions are fully exercised and cleaned up between tests.
plan is called with expectations (method, path, status, optional body/headers), runWithMocks executes an async callback that should trigger those requests and returns the callback result once all planned responses were served. @testassertComplete throws an error that lists any expected interactions that were never hit (by method and path). When everything was exercised, it returns silently. @testpending reports the remaining expectations at any moment, shrinking as requests are matched and reaching an empty array when all are fulfilled. @testreset cancels any in-flight or pending mocks and removes interceptors so new plans start clean; after a reset, pending is empty and previous expectations do not influence subsequent runs. @testexport type MockExpectation = {
method: string;
path: string;
status: number;
body?: unknown;
headers?: Record<string, string>;
};
export class MockSession {
constructor(baseUrl: string);
plan(expectations: MockExpectation[]): void;
pending(): string[];
assertComplete(): void;
reset(): void;
runWithMocks<T>(action: () => Promise<T>): Promise<T>;
}HTTP interception used to stage expectations, verify consumption, and clean up network hooks between runs.