Skip to content

Commit 97b056b

Browse files
committed
fix: integration tests support for Node 19+
1 parent 0ef276e commit 97b056b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changeset/lazy-squids-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ima/plugin-testing-integration": patch
3+
---
4+
5+
Fix support for Node 19+, which encounters `TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.`. As a hotfix, we are now replacing `global.CustomEvent` (which comes with Node 19) with jsdom version of `CustomEvent` to keep the same behavior as in Node 18.

packages/plugin-testing-integration/src/app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ async function initImaApp(bootConfigMethods = {}) {
8686
...Object.getOwnPropertyDescriptors(global),
8787
});
8888

89+
// @TODO: The way we copy `window` properties to `global` is not correct,
90+
// we should switch to `global-jsdom`, or take its implementation
91+
// as an inspiration for our own implementation
92+
global.CustomEvent = window.CustomEvent; // Hotfix for Node 19+, we can remove this once we switch to `global-jsdom`
93+
8994
// set debug before IMA env debug
9095
global.$Debug = true;
9196

0 commit comments

Comments
 (0)