Files
Alfred/tests/happydom.ts

19 lines
644 B
TypeScript

import { GlobalRegistrator } from "@happy-dom/global-registrator";
// 保存 Node/Bun 原生实现,避免被 happy-dom 覆盖导致服务端测试失败
const nativeFetch = globalThis.fetch;
const nativeResponse = globalThis.Response;
const nativeRequest = globalThis.Request;
const nativeHeaders = globalThis.Headers;
const nativeFormData = globalThis.FormData;
const nativeBlob = globalThis.Blob;
GlobalRegistrator.register();
globalThis.fetch = nativeFetch;
globalThis.Response = nativeResponse;
globalThis.Request = nativeRequest;
globalThis.Headers = nativeHeaders;
globalThis.FormData = nativeFormData;
globalThis.Blob = nativeBlob;