Skip to content

Commit

Permalink
fix(happy-dom): fixes issue related to errors thrown inside scripts, …
Browse files Browse the repository at this point in the history
…timers and event listeners not being catched by vitest
  • Loading branch information
capricorn86 committed Sep 18, 2023
1 parent b50cf7a commit 71afb68
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/vitest/src/integrations/env/happy-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ export default <Environment>({
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
Expand All @@ -36,6 +41,10 @@ export default <Environment>({
...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 })
Expand Down

0 comments on commit 71afb68

Please sign in to comment.