2024-08-27 09:45:39 -04:00
|
|
|
/*
|
2024-09-06 10:22:13 +02:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2024-08-27 09:45:39 -04:00
|
|
|
|
2025-02-18 17:59:58 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-06 10:22:13 +02:00
|
|
|
Please see LICENSE in the repository root for full details.
|
2024-08-27 09:45:39 -04:00
|
|
|
*/
|
2024-09-05 16:23:44 -04:00
|
|
|
|
2024-08-27 09:45:39 -04:00
|
|
|
import "global-jsdom/register";
|
2024-11-14 19:06:38 +01:00
|
|
|
import "@formatjs/intl-durationformat/polyfill";
|
|
|
|
|
import "@formatjs/intl-segmenter/polyfill";
|
2024-08-27 09:45:39 -04:00
|
|
|
import i18n from "i18next";
|
|
|
|
|
import posthog from "posthog-js";
|
|
|
|
|
import { initReactI18next } from "react-i18next";
|
2024-09-05 16:23:44 -04:00
|
|
|
import { afterEach } from "vitest";
|
2024-08-27 09:45:39 -04:00
|
|
|
import { cleanup } from "@testing-library/react";
|
2024-09-05 16:23:44 -04:00
|
|
|
import "vitest-axe/extend-expect";
|
2025-03-13 13:58:43 +01:00
|
|
|
import { logger } from "matrix-js-sdk/lib/logger";
|
2024-11-25 20:22:02 +00:00
|
|
|
import "@testing-library/jest-dom/vitest";
|
2024-08-27 09:45:39 -04:00
|
|
|
|
2024-12-04 14:51:29 +00:00
|
|
|
import EN from "../locales/en/app.json";
|
2024-08-27 09:45:39 -04:00
|
|
|
import { Config } from "./config/Config";
|
|
|
|
|
|
|
|
|
|
// Bare-minimum i18n config
|
2024-09-10 09:49:35 +02:00
|
|
|
i18n
|
|
|
|
|
.use(initReactI18next)
|
|
|
|
|
.init({
|
2024-12-04 14:51:29 +00:00
|
|
|
lng: "en",
|
|
|
|
|
fallbackLng: "en",
|
|
|
|
|
supportedLngs: ["en"],
|
2024-11-14 19:06:38 +01:00
|
|
|
// We embed the translations, so that it never needs to fetch
|
|
|
|
|
resources: {
|
2024-12-04 14:51:29 +00:00
|
|
|
en: {
|
2025-03-03 14:37:29 +01:00
|
|
|
translation: EN,
|
2024-11-14 19:06:38 +01:00
|
|
|
},
|
|
|
|
|
},
|
2024-09-10 09:49:35 +02:00
|
|
|
interpolation: {
|
|
|
|
|
escapeValue: false, // React has built-in XSS protections
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => logger.warn("Failed to init i18n for testing", e));
|
2024-08-27 09:45:39 -04:00
|
|
|
|
|
|
|
|
Config.initDefault();
|
|
|
|
|
posthog.opt_out_capturing();
|
|
|
|
|
|
2024-09-05 16:23:44 -04:00
|
|
|
afterEach(cleanup);
|
2024-09-06 13:15:34 -04:00
|
|
|
|
|
|
|
|
// Used by a lot of components
|
|
|
|
|
window.matchMedia = global.matchMedia = (): MediaQueryList =>
|
|
|
|
|
({
|
|
|
|
|
matches: false,
|
|
|
|
|
addEventListener: () => {},
|
|
|
|
|
removeEventListener: () => {},
|
|
|
|
|
}) as Partial<MediaQueryList> as MediaQueryList;
|