2023-04-12 11:47:39 +02:00
|
|
|
/*
|
|
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { env } from "process";
|
|
|
|
|
|
|
|
import type { Config } from "jest";
|
|
|
|
|
|
|
|
const config: Config = {
|
|
|
|
testEnvironment: "jsdom",
|
|
|
|
testMatch: ["<rootDir>/test/**/*-test.[jt]s?(x)"],
|
2023-08-09 10:39:48 +02:00
|
|
|
globalSetup: "<rootDir>/test/globalSetup.ts",
|
2024-07-04 20:08:06 +02:00
|
|
|
setupFiles: ["jest-canvas-mock", "web-streams-polyfill/polyfill"],
|
2023-08-09 10:39:48 +02:00
|
|
|
setupFilesAfterEnv: ["<rootDir>/test/setupTests.ts"],
|
2023-04-12 11:47:39 +02:00
|
|
|
moduleNameMapper: {
|
|
|
|
"\\.(gif|png|ttf|woff2)$": "<rootDir>/__mocks__/imageMock.js",
|
|
|
|
"\\.svg$": "<rootDir>/__mocks__/svg.js",
|
|
|
|
"\\$webapp/i18n/languages.json": "<rootDir>/__mocks__/languages.json",
|
|
|
|
"decoderWorker\\.min\\.js": "<rootDir>/__mocks__/empty.js",
|
|
|
|
"decoderWorker\\.min\\.wasm": "<rootDir>/__mocks__/empty.js",
|
|
|
|
"waveWorker\\.min\\.js": "<rootDir>/__mocks__/empty.js",
|
2023-11-13 19:35:04 +01:00
|
|
|
"workers/(.+)Factory": "<rootDir>/__mocks__/workerFactoryMock.js",
|
2023-04-12 11:47:39 +02:00
|
|
|
"^!!raw-loader!.*": "jest-raw-loader",
|
2023-11-13 19:52:15 +01:00
|
|
|
"recorderWorkletFactory": "<rootDir>/__mocks__/empty.js",
|
2023-04-12 11:47:39 +02:00
|
|
|
},
|
|
|
|
transformIgnorePatterns: ["/node_modules/(?!matrix-js-sdk).+$"],
|
2023-08-22 16:10:47 +02: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 11:47:39 +02:00
|
|
|
coverageReporters: ["text-summary", "lcov"],
|
|
|
|
testResultsProcessor: "@casualbot/jest-sonar-reporter",
|
2024-02-07 18:26:05 +01:00
|
|
|
prettierPath: null,
|
2023-04-12 11:47:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// if we're running under GHA, enable the GHA reporter
|
|
|
|
if (env["GITHUB_ACTIONS"] !== undefined) {
|
|
|
|
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 16:46:50 +02:00
|
|
|
reporters.push("<rootDir>/test/slowReporter.cjs");
|
2023-04-12 11:47:39 +02:00
|
|
|
}
|
|
|
|
config.reporters = reporters;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default config;
|