docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Configure HTTP mocks for a product search service so integration tests can run without hitting the real API. The helper should respond to dynamic product paths and query-driven searches when pointed at a configurable base URL.
{baseUrl}/products/<any-sku> returns HTTP 200 with JSON { "sku": "<sku>", "source": "mock" }, where <sku> echoes the requested segment without predefining the values. @test{baseUrl}/search with query parameters q=<term> and repeated tags entries (e.g., tags=spring&tags=sale) returns HTTP 200 with JSON containing the received term, an array of the tags in their received order, and a stubbed results array keyed by those tags. The match must succeed regardless of query parameter ordering. @test{baseUrl}/search with category=home%2Fdecor returns HTTP 200 with JSON { "category": "home%2Fdecor", "results": ["encoded-category"] }; a request where the slash is unencoded should not use this mock. @testexport interface CatalogMockHandle {
/**
* Lists any expected calls that have not yet been made.
*/
pending(): string[];
/**
* Removes all installed mocks and restores normal network behavior.
*/
restore(): void;
}
/**
* Installs HTTP mocks for the product search service at the provided baseUrl.
* Returns a handle to inspect outstanding expectations and remove the mocks.
*/
export function installCatalogMocks(baseUrl: string): CatalogMockHandle;
/**
* Removes the mocks installed by installCatalogMocks and clears any pending expectations.
*/
export function resetCatalogMocks(): void;Intercepts HTTP requests for the product search service and matches paths and queries.