From 74bdf3b07d69c0d435f4fa477318ac98bc787643 Mon Sep 17 00:00:00 2001 From: StroepWafel <109832156+StroepWafel@users.noreply.github.com> Date: Mon, 7 Sep 2026 16:40:44 +0930 Subject: [PATCH] Update jest.setup.ts --- src/test/jest.setup.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/jest.setup.ts b/src/test/jest.setup.ts index 57630f1b..0f970884 100644 --- a/src/test/jest.setup.ts +++ b/src/test/jest.setup.ts @@ -11,6 +11,22 @@ if (typeof globalThis.CSS === "undefined") { }); } +// requestAnimationFrame / cancelAnimationFrame polyfill +// SettingsState.ts calls requestAnimationFrame to batch subscriber +// notifications, but that API doesn't exist under the Node test +// environment. This provides a minimal setTimeout-based stand-in. +if (typeof globalThis.requestAnimationFrame === "undefined") { + globalThis.requestAnimationFrame = (cb: FrameRequestCallback): number => { + return setTimeout(() => cb(Date.now()), 0) as unknown as number; + }; +} + +if (typeof globalThis.cancelAnimationFrame === "undefined") { + globalThis.cancelAnimationFrame = (handle: number): void => { + clearTimeout(handle); + }; +} + afterEach(() => { __resetBrowserStorageMock(); });