From c21c0efacef7c0ea2c5a33470f62236059900be6 Mon Sep 17 00:00:00 2001 From: David Ortner Date: Tue, 19 Sep 2023 08:42:00 +0200 Subject: [PATCH] fix(happy-dom): catch errors in happy-dom (#4140) --- packages/vitest/src/integrations/env/happy-dom.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/vitest/src/integrations/env/happy-dom.ts b/packages/vitest/src/integrations/env/happy-dom.ts index 9efedcbe47fa..5bcb794cb561 100644 --- a/packages/vitest/src/integrations/env/happy-dom.ts +++ b/packages/vitest/src/integrations/env/happy-dom.ts @@ -9,7 +9,12 @@ export default ({ const { Window } = await importModule('happy-dom') as typeof import('happy-dom') const win = new Window({ ...happyDOM, + console: (console && globalThis.console) ? globalThis.console : undefined, url: happyDOM.url || 'http://localhost:3000', + settings: { + ...happyDOM.settings, + disableErrorCapturing: true, + }, }) as any // TODO: browser doesn't expose Buffer, but a lot of dependencies use it @@ -36,6 +41,10 @@ export default ({ ...happyDOM, console: (console && global.console) ? global.console : undefined, url: happyDOM.url || 'http://localhost:3000', + settings: { + ...happyDOM.settings, + disableErrorCapturing: true, + }, }) const { keys, originals } = populateGlobal(global, win, { bindFunctions: true })