Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: happy-dom v3 crashes #1234

Merged
merged 2 commits into from May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.