From f4d6517bbb51c59df30d1367c57f52a4e18ec9d1 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Tue, 2 Jun 2026 08:29:03 +0200 Subject: [PATCH] Switch from global to globalThis to fix import issues --- src/room/GroupCallView.test.tsx | 5 ++++- src/room/InCallView.test.tsx | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/room/GroupCallView.test.tsx b/src/room/GroupCallView.test.tsx index 2aef571a..577b28d3 100644 --- a/src/room/GroupCallView.test.tsx +++ b/src/room/GroupCallView.test.tsx @@ -63,7 +63,10 @@ vi.mock("react-use-measure", () => ({ vi.hoisted( () => - (global.ImageData = class MockImageData { + // Use globalThis rather than global because vite-plugin-node-polyfills seems + // to rewrite global into an import which then interferes with vitest's hoisting + // which runs before imports. + (globalThis.ImageData = class MockImageData { public data: number[] = []; } as unknown as typeof ImageData), ); diff --git a/src/room/InCallView.test.tsx b/src/room/InCallView.test.tsx index eb210457..c2d8a729 100644 --- a/src/room/InCallView.test.tsx +++ b/src/room/InCallView.test.tsx @@ -57,7 +57,10 @@ import { initializeWidget } from "../widget"; initializeWidget(); vi.hoisted( () => - (global.ImageData = class MockImageData { + // Use globalThis rather than global because vite-plugin-node-polyfills seems + // to rewrite global into an import which then interferes with vitest's hoisting + // which runs before imports. + (globalThis.ImageData = class MockImageData { public data: number[] = []; } as unknown as typeof ImageData), );