Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/serpapi/src/utils.ts>_internals

Scrape and parse search engine results using SerpApi.
Go to Latest
variable _internals
import { _internals } from "https://deno.land/x/serpapi@0.0.3/src/utils.ts";

This _internals object is needed to support stubbing/spying of fetch, execute and getBaseUrl. https://deno.land/manual@v1.28.3/basics/testing/mocking

If fetch is stubbed via globalThis, the test phase of the npm build fails.

const fetchStub = stub(globalThis, "fetch", resolvesNext([new Response("data")]));

dnt shims fetch by relying on the undici package. It replaces all references to fetch with dntShim.fetch. As a side effect, stubbing globalThis.fetch becomes incorrect; we want to stub dntShim.fetch instead.

As a workaround, the _internals object serves as an indirection and we stub the fetch key of this object instead.

type

{ fetch; execute; getBaseUrl; }