chore: jsdom 迁移至 happy-dom

This commit is contained in:
2026-06-06 16:59:11 +08:00
parent 5c0f02f1f8
commit b469662760
6 changed files with 41 additions and 139 deletions

18
tests/happydom.ts Normal file
View File

@@ -0,0 +1,18 @@
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;