Migrate more jest tests to vitest (#33898)

* Migrate more jest tests to vitest

* Fix jest config

* Fix jest config

* Make remaining jest tests type-happy
This commit is contained in:
Michael Telatynski
2026-06-19 15:34:18 +00:00
committed by GitHub
parent fab71c80ed
commit 45234b9c94
62 changed files with 625 additions and 488 deletions
+17 -1
View File
@@ -5,9 +5,12 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { beforeEach } from "vitest";
import { vi, beforeEach } from "vitest";
import fetchMock, { manageFetchMockGlobally } from "@fetch-mock/vitest";
import { mocks } from "../../test/setup/mocks.ts";
import SdkConfig, { DEFAULTS } from "../SdkConfig";
manageFetchMockGlobally();
beforeEach(() => {
@@ -16,3 +19,16 @@ beforeEach(() => {
fetchMock.catch(404);
fetchMock.mockGlobal();
});
// set up AudioContext API mock
vi.stubGlobal("AudioContext", function () {
return mocks.AudioContext;
});
if (globalThis.window === undefined) {
// We are in a node environment, stub a basic window so singletons work
vi.stubGlobal("window", {});
}
// uninitialised SdkConfig causes lots of warnings in console, init with defaults
SdkConfig.put(DEFAULTS);