Migrate more jest tests to vitest (#33922)
* Migrate more jest tests to vitest * Fix jest config * Fix jest config * Make remaining jest tests type-happy * Iterate * Fix Notifier import cycle * Fix tests * Delint * Iterate * Handle SDKContextClass `client` initialisation internally Rather than via MatrixChat - this is predominantly for Lifecycle tests as they don't use a MatrixChat and it doesn't make much sense for this component to own this state. * Fix tests * Iterate * Simplify diff * Improve coverage * Improve coverage * Iterate
This commit is contained in:
@@ -8,6 +8,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
import { vi } from "vitest";
|
||||
|
||||
import { mocks } from "../../test/setup/mocks.ts";
|
||||
import SdkConfig, { DEFAULTS } from "../SdkConfig";
|
||||
|
||||
// set up AudioContext API mock
|
||||
vi.stubGlobal("AudioContext", function () {
|
||||
@@ -28,3 +29,6 @@ if (globalThis.window === undefined) {
|
||||
setTimeout: globalThis.setTimeout,
|
||||
});
|
||||
}
|
||||
|
||||
// uninitialised SdkConfig causes lots of warnings in console, init with defaults
|
||||
SdkConfig.put(DEFAULTS);
|
||||
|
||||
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { beforeEach, afterEach } from "vitest";
|
||||
import { vi, beforeEach, afterEach } from "vitest";
|
||||
import fetchMock, { manageFetchMockGlobally } from "@fetch-mock/vitest";
|
||||
|
||||
import SdkConfig, { DEFAULTS } from "../SdkConfig";
|
||||
@@ -15,6 +15,8 @@ import { setupLanguageMock } from "./setupLanguage.ts";
|
||||
manageFetchMockGlobally();
|
||||
|
||||
beforeEach(() => {
|
||||
vi.stubEnv("TZ", "UTC");
|
||||
|
||||
// set up fetch API mock
|
||||
fetchMock.hardReset();
|
||||
fetchMock.catch(404);
|
||||
|
||||
Reference in New Issue
Block a user