2023-04-12 12:47:27 +03:00
|
|
|
/*
|
2024-09-06 17:44:31 +03:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2023-04-12 12:47:27 +03:00
|
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-06 17:44:31 +03:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2023-04-12 12:47:27 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
import { env } from "process";
|
|
|
|
|
|
|
|
import type { Config } from "jest";
|
|
|
|
|
|
|
|
const config: Config = {
|
|
|
|
testEnvironment: "jsdom",
|
|
|
|
testEnvironmentOptions: {
|
|
|
|
url: "http://localhost/",
|
|
|
|
},
|
|
|
|
testMatch: ["<rootDir>/test/**/*-test.[tj]s?(x)"],
|
2023-08-09 11:39:48 +03:00
|
|
|
globalSetup: "<rootDir>/test/globalSetup.ts",
|
2024-07-04 21:08:06 +03:00
|
|
|
setupFiles: ["jest-canvas-mock", "web-streams-polyfill/polyfill"],
|
2023-08-09 11:39:48 +03:00
|
|
|
setupFilesAfterEnv: ["<rootDir>/test/setupTests.ts"],
|
2023-04-12 12:47:27 +03:00
|
|
|
moduleNameMapper: {
|
|
|
|
"\\.(css|scss|pcss)$": "<rootDir>/__mocks__/cssMock.js",
|
2023-04-12 12:47:39 +03:00
|
|
|
"\\.(gif|png|ttf|woff2)$": "<rootDir>/__mocks__/imageMock.js",
|
|
|
|
"\\.svg$": "<rootDir>/__mocks__/svg.js",
|
|
|
|
"\\$webapp/i18n/languages.json": "<rootDir>/__mocks__/languages.json",
|
2023-04-12 12:47:27 +03:00
|
|
|
"^react$": "<rootDir>/node_modules/react",
|
|
|
|
"^react-dom$": "<rootDir>/node_modules/react-dom",
|
|
|
|
"^matrix-js-sdk$": "<rootDir>/node_modules/matrix-js-sdk/src",
|
2024-10-15 16:57:26 +03:00
|
|
|
"^matrix-react-sdk$": "<rootDir>/src",
|
2023-04-12 12:47:39 +03:00
|
|
|
"decoderWorker\\.min\\.js": "<rootDir>/__mocks__/empty.js",
|
|
|
|
"decoderWorker\\.min\\.wasm": "<rootDir>/__mocks__/empty.js",
|
|
|
|
"waveWorker\\.min\\.js": "<rootDir>/__mocks__/empty.js",
|
2024-10-15 16:57:26 +03:00
|
|
|
"context-filter-polyfill": "<rootDir>/__mocks__/empty.js",
|
|
|
|
"FontManager.ts": "<rootDir>/__mocks__/FontManager.js",
|
2023-11-13 21:35:04 +03:00
|
|
|
"workers/(.+)Factory": "<rootDir>/__mocks__/workerFactoryMock.js",
|
2023-04-12 12:47:27 +03:00
|
|
|
"^!!raw-loader!.*": "jest-raw-loader",
|
2023-11-13 21:52:15 +03:00
|
|
|
"recorderWorkletFactory": "<rootDir>/__mocks__/empty.js",
|
2023-09-05 19:17:25 +03:00
|
|
|
"^fetch-mock$": "<rootDir>/node_modules/fetch-mock",
|
2023-04-12 12:47:27 +03:00
|
|
|
},
|
2023-04-12 12:47:39 +03:00
|
|
|
transformIgnorePatterns: ["/node_modules/(?!matrix-js-sdk).+$"],
|
2023-08-22 17:10:47 +03:00
|
|
|
collectCoverageFrom: [
|
|
|
|
"<rootDir>/src/**/*.{js,ts,tsx}",
|
|
|
|
// getSessionLock is piped into a different JS context via stringification, and the coverage functionality is
|
|
|
|
// not available in that contest. So, turn off coverage instrumentation for it.
|
|
|
|
"!<rootDir>/src/utils/SessionLock.ts",
|
|
|
|
],
|
2023-04-12 12:47:27 +03:00
|
|
|
coverageReporters: ["text-summary", "lcov"],
|
|
|
|
testResultsProcessor: "@casualbot/jest-sonar-reporter",
|
2024-02-07 20:26:05 +03:00
|
|
|
prettierPath: null,
|
2024-10-14 19:11:58 +03:00
|
|
|
moduleDirectories: ["node_modules", "test/test-utils"],
|
2023-04-12 12:47:27 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// if we're running under GHA, enable the GHA reporter
|
|
|
|
if (env["GITHUB_ACTIONS"] !== undefined) {
|
2023-04-12 12:47:39 +03:00
|
|
|
const reporters: Config["reporters"] = [["github-actions", { silent: false }], "summary"];
|
|
|
|
|
|
|
|
// if we're running against the develop branch, also enable the slow test reporter
|
|
|
|
if (env["GITHUB_REF"] == "refs/heads/develop") {
|
2024-08-27 17:46:50 +03:00
|
|
|
reporters.push("<rootDir>/test/slowReporter.cjs");
|
2023-04-12 12:47:39 +03:00
|
|
|
}
|
|
|
|
config.reporters = reporters;
|
2023-04-12 12:47:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export default config;
|