Skip to content

Commit

Permalink
fix: happy-dom v3 crashes (#1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed May 5, 2022
1 parent 5ff4331 commit ae2c561
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bench/package.json
Expand Up @@ -9,7 +9,7 @@
"@actions/core": "^1.7.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.0.1",
"@happy-dom/jest-environment": "^2.55.0",
"@happy-dom/jest-environment": "^3.1.1",
"@types/benchmark": "^2.1.1",
"benchmark": "^2.1.4",
"esmo": "^0.14.1",
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -69,7 +69,6 @@
"pnpm": {
"overrides": {
"vite": "^2.9.5",
"happy-dom": "^2.55.0",
"vitest": "workspace:*"
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/package.json
Expand Up @@ -109,7 +109,7 @@
"fast-glob": "^3.2.11",
"find-up": "^6.3.0",
"flatted": "^3.2.5",
"happy-dom": "^2.55.0",
"happy-dom": "^3.1.1",
"jsdom": "^19.0.0",
"log-update": "^5.0.1",
"magic-string": "^0.26.1",
Expand Down
6 changes: 4 additions & 2 deletions packages/vitest/src/integrations/env/happy-dom.ts
Expand Up @@ -5,8 +5,10 @@ import { getWindowKeys } from './utils'
export default <Environment>({
name: 'happy-dom',
async setup(global) {
const { Window } = await importModule('happy-dom') as typeof import('happy-dom')
const win: any = new Window()
// happy-dom v3 introduced a breaking change to Window, but
// provides GlobalWindow as a way to use previous behaviour
const { Window, GlobalWindow } = await importModule('happy-dom') as typeof import('happy-dom')
const win: any = new (GlobalWindow || Window)()

const keys = getWindowKeys(global, win)

Expand Down
21 changes: 10 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ae2c561

Please sign in to comment.