From 7df7f535a61fc3139f7d93305ed98046d9a4d9e0 Mon Sep 17 00:00:00 2001 From: Ayush Pahwa Date: Thu, 21 Nov 2024 20:39:02 +0530 Subject: [PATCH] update: add polyfil for jest tests --- app/client/test/setup.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/client/test/setup.ts b/app/client/test/setup.ts index c7f3e4009fd..31f5bfefc83 100644 --- a/app/client/test/setup.ts +++ b/app/client/test/setup.ts @@ -24,6 +24,14 @@ jest.mock("../src/api/Api.ts", () => ({ default: class Api { }, })); +// Polyfill for `structuredClone` if not available +// This is needed for eslint jest tests +if (typeof global.structuredClone === "undefined") { + global.structuredClone = (obj) => { + return JSON.parse(JSON.stringify(obj)); + }; +} + beforeAll(() => { window.IntersectionObserver = jest .fn()