Switch from global to globalThis to fix import issues

This commit is contained in:
Johannes Marbach
2026-06-02 08:29:03 +02:00
parent 576119663f
commit f4d6517bbb
2 changed files with 8 additions and 2 deletions
+4 -1
View File
@@ -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),
);
+4 -1
View File
@@ -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),
);