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

x/pastedeno/dev_deps.ts>MockFetch#intercept

Universal Pastebin client for Deno/Node
Latest
method MockFetch.prototype.intercept
import { MockFetch } from "https://deno.land/x/pastedeno@0.6.2/dev_deps.ts";

Intercept a global fetch API call for the defined inputs.

import { MockFetch } from "https://deno.land/x/deno_mock_fetch@1.0.1/mod.ts";

const mockFetch = new MockFetch();
mockFetch
  // Intercept `GET https://example.com/hello`
  .intercept("https://example.com/hello", { method: "GET" })
  // Response with status `200` and text `hello`
  .response("hello", { status: 200 });

Parameters

input: URL | Request | MockMatcher
optional
init: MockRequestInit

Returns

MockInterceptor