Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno_mock_fetch/mod.ts>MockInterceptor

Deno mock fetch implementation
Latest
class MockInterceptor
Re-export
import { MockInterceptor } from "https://deno.land/x/deno_mock_fetch@1.0.1/mod.ts";

Defines an interceptor for a Mock. Instantiated when MockFetch.intercept(...) is called.

Constructors

new
MockInterceptor(
mockRequests: MockRequest[],
input: URL | Request | MockMatcher,
)

Methods

Set default response headers on the interceptor for subsequent responses

response(body?: BodyInit | null, init?: ResponseInit): MockScope

Mock a request with a defined response.

Set response content length header for responses. Default: off.

At this time, this only calculates for response body init inputs of type string.

throwError(error: Error): MockScope

Mock a request with a defined error that will be thrown when global fetch is called.