From 97b056b4b23aa7844db6c1a5c6c7d36c8b4a1131 Mon Sep 17 00:00:00 2001 From: Filip Satek Date: Fri, 10 May 2024 11:27:50 +0200 Subject: [PATCH] fix: integration tests support for Node 19+ --- .changeset/lazy-squids-unite.md | 5 +++++ packages/plugin-testing-integration/src/app.js | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/lazy-squids-unite.md diff --git a/.changeset/lazy-squids-unite.md b/.changeset/lazy-squids-unite.md new file mode 100644 index 00000000..b7cce19a --- /dev/null +++ b/.changeset/lazy-squids-unite.md @@ -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. diff --git a/packages/plugin-testing-integration/src/app.js b/packages/plugin-testing-integration/src/app.js index 7377cfc4..e97ac663 100644 --- a/packages/plugin-testing-integration/src/app.js +++ b/packages/plugin-testing-integration/src/app.js @@ -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;