fix: happy-dom v3 crashes (#1234)

This commit is contained in:
Vladimir 2022-05-05 19:54:48 +03:00 committed by GitHub
parent 5ff43314d1
commit ae2c561784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 16 deletions

View File

@ -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",

View File

@ -69,7 +69,6 @@
"pnpm": {
"overrides": {
"vite": "^2.9.5",
"happy-dom": "^2.55.0",
"vitest": "workspace:*"
}
},

View File

@ -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",

View File

@ -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)

21
pnpm-lock.yaml generated
View File

@ -2,7 +2,6 @@ lockfileVersion: 5.4
overrides:
vite: ^2.9.5
happy-dom: ^2.55.0
vitest: workspace:*
importers:
@ -144,7 +143,7 @@ importers:
examples/lit:
specifiers:
'@vitest/ui': latest
happy-dom: ^2.55.0
happy-dom: latest
lit: ^2.2.3
vite: ^2.9.5
vitest: workspace:*
@ -152,7 +151,7 @@ importers:
lit: 2.2.3
devDependencies:
'@vitest/ui': link:../../packages/ui
happy-dom: 2.55.0
happy-dom: 3.1.1
vite: 2.9.5
vitest: link:../../packages/vitest
@ -216,7 +215,7 @@ importers:
'@types/react-test-renderer': ^17.0.2
'@vitejs/plugin-react': 1.3.1
'@vitest/ui': latest
happy-dom: ^2.55.0
happy-dom: latest
jsdom: latest
react: ^17.0.2
react-test-renderer: 17.0.2
@ -228,7 +227,7 @@ importers:
'@types/react-test-renderer': 17.0.2
'@vitejs/plugin-react': 1.3.1
'@vitest/ui': link:../../packages/ui
happy-dom: 2.55.0
happy-dom: 3.1.1
jsdom: 19.0.0
react-test-renderer: 17.0.2_react@17.0.2
vitest: link:../../packages/vitest
@ -471,7 +470,7 @@ importers:
specifiers:
'@vitejs/plugin-vue': ^2.3.1
'@vue/test-utils': ^2.0.0-rc.21
happy-dom: ^2.55.0
happy-dom: latest
unplugin-auto-import: ^0.7.1
unplugin-vue-components: ^0.19.3
vitest: workspace:*
@ -481,7 +480,7 @@ importers:
devDependencies:
'@vitejs/plugin-vue': 2.3.1_vue@3.2.33
'@vue/test-utils': 2.0.0-rc.21_vue@3.2.33
happy-dom: 2.55.0
happy-dom: 3.1.1
unplugin-auto-import: 0.7.1
unplugin-vue-components: 0.19.3_vue@3.2.33
vitest: link:../../packages/vitest
@ -634,7 +633,7 @@ importers:
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
local-pkg: ^0.4.1
log-update: ^5.0.1
@ -685,7 +684,7 @@ importers:
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
@ -12153,8 +12152,8 @@ packages:
uglify-js: 3.15.4
dev: true
/happy-dom/2.55.0:
resolution: {integrity: sha512-CHDMBRau+l/yKQL+ANmexRAC8FRCuYbXRSpu/GbLVyfqkrlBzV7OSNd5C5HZ+pVFtFv1bFJYC5r+xrqgGQuq5w==}
/happy-dom/3.1.1:
resolution: {integrity: sha512-yomqZv0JJ3FSQ/OZXiDSNOqw/vxZEzrFpxXausyyGPMICZs3KIGfQt+X/007abXkQWRb1SDeetM4PqOM0cagfQ==}
dependencies:
css.escape: 1.5.1
he: 1.2.0