https://github.com/yamachu/jsdom-with-window-prefix
https://github.com/yamachu/jsdom-with-window-prefix
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yamachu/jsdom-with-window-prefix
- Owner: yamachu
- Created: 2023-10-26T11:34:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-26T11:38:24.000Z (over 1 year ago)
- Last Synced: 2025-01-20T08:28:25.375Z (6 months ago)
- Language: TypeScript
- Size: 54.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# global-jsdom + CustomEvent + Node 20 が落ちる再現
## 対策
### 対策1
see: https://github.com/yamachu/jsdom-with-window-prefix/pull/1
vitest を使っているのであれば、global-jsdom を使わないで、
```ts
// @vitest-environment jsdom
```みたいに [vitest-environment](https://vitest.dev/config/#environment) に乗っかる
### 対策2
see: https://github.com/yamachu/jsdom-with-window-prefix/pull/2
global-jsdom を使うなら、ブラウザに実装されている API では `window.` を付けて、jsdom から渡っている API を使用しているという様に明示する
```diff
- new CustomEvent('foo')
+ new window.CustomEvent('foo')
```