UNPKG

@rstest/core

Version:
37 lines (36 loc) 1.2 kB
import 'module'; /*#__PURE__*/ import.meta.url; import { checkPkgInstalled } from "./7913.js"; import { installGlobal, addDefaultErrorHandler } from "./0~3062.js"; const environment = { name: 'happy-dom', setup: async (global, options = {})=>{ checkPkgInstalled('happy-dom'); const { Window } = await import("happy-dom"); const win = new Window({ ...options, url: options.url || 'http://localhost:3000', console: console && global.console ? global.console : void 0 }); const cleanupGlobal = installGlobal(global, win, { additionalKeys: [ 'Request', 'Response', 'MessagePort', 'fetch' ] }); const cleanupHandler = addDefaultErrorHandler(global); return { async teardown () { cleanupHandler(); if (win.close && win.happyDOM.abort) { await win.happyDOM.abort(); win.close(); } else await win.happyDOM.cancelAsync(); cleanupGlobal(); } }; } }; export { environment };