Skip to content

Commit

Permalink
fix: integration tests support for Node 19+
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipoliko committed May 10, 2024
1 parent 0ef276e commit 97b056b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-squids-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ima/plugin-testing-integration": patch
---

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.
5 changes: 5 additions & 0 deletions packages/plugin-testing-integration/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ async function initImaApp(bootConfigMethods = {}) {
...Object.getOwnPropertyDescriptors(global),
});

// @TODO: The way we copy `window` properties to `global` is not correct,
// we should switch to `global-jsdom`, or take its implementation
// as an inspiration for our own implementation
global.CustomEvent = window.CustomEvent; // Hotfix for Node 19+, we can remove this once we switch to `global-jsdom`

// set debug before IMA env debug
global.$Debug = true;

Expand Down

0 comments on commit 97b056b

Please sign in to comment.