From c58942b59b631828a8626915a330b7c8faba4889 Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Thu, 26 Dec 2024 23:56:36 +0100 Subject: [PATCH] Expose MessagePort class for Undici v7 --- UI/tests/common/jest-setup.js | 2 +- UI/tests/common/mocks/server.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/UI/tests/common/jest-setup.js b/UI/tests/common/jest-setup.js index e9abf7514e..3304da72e0 100644 --- a/UI/tests/common/jest-setup.js +++ b/UI/tests/common/jest-setup.js @@ -8,10 +8,10 @@ import { afterEach } from "@jest/globals"; import "core-js"; +import { server } from "./mocks/server.js"; import { setGlobalOrigin } from "undici"; import "./mocks/lsmb_elements"; -import { server } from "./mocks/server.js"; Object.defineProperty(window, "lsmbConfig", { writable: true, diff --git a/UI/tests/common/mocks/server.js b/UI/tests/common/mocks/server.js index 428359a091..774bcdd56f 100644 --- a/UI/tests/common/mocks/server.js +++ b/UI/tests/common/mocks/server.js @@ -1,7 +1,14 @@ /** @format */ +/* global globalThis */ import { setupServer } from "msw/node"; import { handlers } from "./handlers"; +const { MessageChannel, MessagePort } = require("node:worker_threads"); // This configures a Service Server with the given request handlers. export const server = setupServer(...handlers); + +Object.defineProperties(globalThis, { + MessageChannel: { value: MessageChannel }, + MessagePort: { value: MessagePort } +});