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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user