Mock options
Optionalserve?: (request: Request) => Promise<Response>The function computing the response to each exchange; defaults to a 200 OK response carrying
an empty JSON object
Optionaldelay?: numberThe number of milliseconds to wait before answering each exchange; defaults to 0
A Middleware answering every exchange with the response computed by serve, ignoring the
Fetch implementation it wraps
RangeError If delay is not a non-negative number of milliseconds within the range
setTimeout() handles
Creates a middleware answering exchanges with locally computed responses.
Stands in for the network, in place of the standard function createFetch would otherwise delegate to: each exchange is handed to
serveas aRequestand answered with the response it returns oncedelaymilliseconds have elapsed, so that loading states, timeouts and error handling are exercised as they would be against a live server. A failure reported byservereaches the caller as a transport failure would.An exchange aborted by its signal before it is answered is rejected with the abort reason, as the standard function does, and
serveis not consulted.Ignores the Fetch implementation it wraps: middlewares declared before it process exchanges as usual, while middlewares declared after it are never reached, so this middleware is to be declared last in a chain.