diff --git a/packages/fetch-http-handler/src/fetch-http-handler.browser.spec.ts b/packages/fetch-http-handler/src/fetch-http-handler.browser.spec.ts index c3ff99adf7c..779a140ed72 100644 --- a/packages/fetch-http-handler/src/fetch-http-handler.browser.spec.ts +++ b/packages/fetch-http-handler/src/fetch-http-handler.browser.spec.ts @@ -6,12 +6,31 @@ import { createRequest } from "./create-request"; import { FetchHttpHandler, keepAliveSupport } from "./fetch-http-handler"; vi.mock("./create-request", async () => { - const actual: any = await vi.importActual("./create-request"); return { - createRequest: vi.fn().mockImplementation(actual.createRequest), + createRequest: vi.fn().mockImplementation((_url, options) => { + const url = new URL(_url); + return { + protocol: url.protocol, + hostname: url.hostname, + ...options, + } as any; + }), }; }); +vi.spyOn(global, "fetch").mockImplementation((async () => { + return { + headers: { + entries() { + return []; + }, + }, + async blob() { + return undefined; + }, + }; +}) as any); + (typeof Blob === "function" ? describe : describe.skip)(FetchHttpHandler.name, () => { interface MockHttpRequestOptions { method?: string; @@ -23,7 +42,7 @@ vi.mock("./create-request", async () => { } const getMockHttpRequest = (options: MockHttpRequestOptions): HttpRequest => - new HttpRequest({ hostname: "example.com", ...options }); + new HttpRequest({ hostname: "localhost", protocol: "http", ...options }); describe("fetch", () => { beforeAll(() => {