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), );