From 3e40e58b1228fd0934db80bc16556a9f46a608c6 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 29 Jun 2026 18:08:32 +0100 Subject: [PATCH] Mock out window.addEventListener globally (#34028) * Mock out window.addEventListener globally As some code uses it * Move to setupGlobals * clean up import * Only needed if we don't have happy-dom * thank you! Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --- apps/web/src/test/setupGlobals.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/web/src/test/setupGlobals.ts b/apps/web/src/test/setupGlobals.ts index bdcb327151..0867071bcc 100644 --- a/apps/web/src/test/setupGlobals.ts +++ b/apps/web/src/test/setupGlobals.ts @@ -16,5 +16,9 @@ vi.stubGlobal("AudioContext", function () { if (globalThis.window === undefined) { // We are in a node environment, stub a basic window so singletons work - vi.stubGlobal("window", {}); + vi.stubGlobal("window", { + // Mock this as some code assumes it exists (needs to be done at the top level as + // things try to access it before the beforeEach blocks run) + addEventListener: vi.fn(), + }); }