docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Create a helper that sets up HTTP mocks keyed off the shape and content of request bodies for a single base URL. The helper should make it easy to prime expectations for different body formats and to verify that every expectation was satisfied after client calls complete. Each mock is primed via the API, exercised by client calls, and then verified through the helper.
mockWebhook("signup", uuidPattern), a POST to /webhook with JSON body {"event":"signup","payload":{"id":"123e4567-e89b-12d3-a456-426614174000","metadata":{"source":"web"}}} returns a 202 response with {"status":"accepted"}; a subsequent POST to the same path with payload.id: "invalid" leaves one expectation pending so verification fails. @testmockMetrics(["http.latency", "db.connections"]), posting an NDJSON string that includes lines for metrics named http.latency and db.connections to /metrics returns 200 with body ok; omitting one of those metric names leaves the expectation unmet during verification. @testmockUpload(), posting a binary buffer that begins with the PNG signature (89 50 4E 47 in hex) to /upload returns 201 with body stored; sending plain text to the same path keeps the expectation pending when verified. @testassertComplete() reports any pending expectations and cleanup() removes all mocks so new tests start cleanly. @test/**
* Creates request body-aware mocks tied to a base URL.
* @param {string} baseUrl base URL of the external service being mocked.
* @returns {{
* mockWebhook(eventName: string, idPattern: RegExp): void,
* mockMetrics(expectedNames: string[]): void,
* mockUpload(): void,
* assertComplete(): void,
* cleanup(): void
* }}
*/
function createBodyMocker(baseUrl) {}
module.exports = { createBodyMocker };Mocks outbound HTTP requests with request body matching support.