chore: jsdom 迁移至 happy-dom
This commit is contained in:
18
tests/happydom.ts
Normal file
18
tests/happydom.ts
Normal 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;
|
||||
Reference in New Issue
Block a user