@@ -5,13 +5,30 @@ import { server } from "./src/testHelpers/server"
55import "jest-location-mock"
66import { TextEncoder , TextDecoder } from "util"
77import { Blob } from "buffer"
8+ import { fetch , Request , Response , Headers } from "@remix-run/web-fetch"
89
910global . TextEncoder = TextEncoder
1011// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Polyfill for jsdom
1112global . TextDecoder = TextDecoder as any
1213// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Polyfill for jsdom
1314global . Blob = Blob as any
1415
16+ // From REMIX https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/__tests__/setup.ts
17+ if ( ! global . fetch ) {
18+ // Built-in lib.dom.d.ts expects `fetch(Request | string, ...)` but the web
19+ // fetch API allows a URL so@remix -run/web-fetch defines
20+ // `fetch(string | URL | Request, ...)`
21+ //@ts -expect-error -- Polyfill for jsdom
22+ global . fetch = fetch
23+ // Same as above, lib.dom.d.ts doesn't allow a URL to the Request constructor
24+ //@ts -expect-error -- Polyfill for jsdom
25+ global . Request = Request
26+ // web-std/fetch Response does not currently implement Response.error()
27+ //@ts -expect-error -- Polyfill for jsdom
28+ global . Response = Response
29+ global . Headers = Headers
30+ }
31+
1532// Polyfill the getRandomValues that is used on utils/random.ts
1633Object . defineProperty ( global . self , "crypto" , {
1734value :{