Files
ThreadNet-Web/apps/web/src/test/setupTests.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
929 B
TypeScript
Raw Normal View History

2026-06-15 14:24:33 +01:00
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
2026-07-07 10:50:40 +01:00
import { vi, beforeEach, afterEach } from "vitest";
2026-06-15 14:24:33 +01:00
import fetchMock, { manageFetchMockGlobally } from "@fetch-mock/vitest";
2026-06-19 16:34:18 +01:00
import SdkConfig, { DEFAULTS } from "../SdkConfig";
import "./setupGlobals.ts";
import { setupLanguageMock } from "./setupLanguage.ts";
2026-06-19 16:34:18 +01:00
2026-07-30 10:11:29 +01:00
declare global {
var IS_REACT_ACT_ENVIRONMENT: boolean;
}
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
2026-06-15 14:24:33 +01:00
manageFetchMockGlobally();
beforeEach(() => {
2026-07-07 10:50:40 +01:00
vi.stubEnv("TZ", "UTC");
2026-06-15 14:24:33 +01:00
// set up fetch API mock
fetchMock.hardReset();
fetchMock.catch(404);
fetchMock.mockGlobal();
setupLanguageMock();
2026-06-15 14:24:33 +01:00
});
2026-06-19 16:34:18 +01:00
afterEach(() => fetchMock.callHistory.flush());
2026-06-19 16:34:18 +01:00
// uninitialised SdkConfig causes lots of warnings in console, init with defaults
SdkConfig.put(DEFAULTS);