|
| 1 | +/* |
| 2 | +Copyright 2025 Element Creations Ltd. |
| 3 | +
|
| 4 | +SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial |
| 5 | +Please see LICENSE files in the repository root for full details. |
| 6 | +*/ |
| 7 | + |
| 8 | +import { env } from "process"; |
| 9 | + |
| 10 | +import type { Config } from "jest"; |
| 11 | + |
| 12 | +const config: Config = { |
| 13 | + testEnvironment: "jsdom", |
| 14 | + testEnvironmentOptions: { |
| 15 | + url: "http://localhost/", |
| 16 | + }, |
| 17 | + testMatch: ["<rootDir>/src/**/*.test.[tj]s?(x)"], |
| 18 | + setupFilesAfterEnv: ["<rootDir>/src/test/setupTests.ts"], |
| 19 | + moduleNameMapper: { |
| 20 | + // Support CSS module |
| 21 | + "\\.(module.css)$": "identity-obj-proxy", |
| 22 | + "\\.(css|scss|pcss)$": "<rootDir>/__mocks__/cssMock.js", |
| 23 | + "\\.(gif|png|ttf|woff2)$": "<rootDir>/__mocks__/imageMock.js", |
| 24 | + "\\.svg$": "<rootDir>/__mocks__/svg.js", |
| 25 | + "\\$webapp/i18n/languages.json": "<rootDir>/../../__mocks__/languages.json", |
| 26 | + "^react$": "<rootDir>/node_modules/react", |
| 27 | + "^react-dom$": "<rootDir>/node_modules/react-dom", |
| 28 | + "waveWorker\\.min\\.js": "<rootDir>/__mocks__/empty.js", |
| 29 | + "context-filter-polyfill": "<rootDir>/__mocks__/empty.js", |
| 30 | + "workers/(.+)Factory": "<rootDir>/__mocks__/workerFactoryMock.js", |
| 31 | + }, |
| 32 | + transformIgnorePatterns: [ |
| 33 | + "/node_modules/(?!(mime|matrix-js-sdk|uuid|p-retry|is-network-error|react-merge-refs)).+$", |
| 34 | + ], |
| 35 | + collectCoverageFrom: [ |
| 36 | + "<rootDir>/src/**/*.{js,ts,tsx}", |
| 37 | + "<rootDir>/packages/**/*.{js,ts,tsx}", |
| 38 | + // Coverage chokes on type definition files |
| 39 | + "!<rootDir>/src/**/*.d.ts", |
| 40 | + ], |
| 41 | + coverageReporters: ["text-summary", "lcov"], |
| 42 | + testResultsProcessor: "@casualbot/jest-sonar-reporter", |
| 43 | + prettierPath: null, |
| 44 | + moduleDirectories: ["node_modules", "./src/test/utils"], |
| 45 | +}; |
| 46 | + |
| 47 | +// if we're running under GHA, enable the GHA reporter |
| 48 | +if (env["GITHUB_ACTIONS"] !== undefined) { |
| 49 | + const reporters: Config["reporters"] = [["github-actions", { silent: false }], "summary"]; |
| 50 | + |
| 51 | + // if we're running against the develop branch, also enable the slow test reporter |
| 52 | + if (env["GITHUB_REF"] == "refs/heads/develop") { |
| 53 | + reporters.push("<rootDir>/test/slowReporter.cjs"); |
| 54 | + } |
| 55 | + config.reporters = reporters; |
| 56 | +} |
| 57 | + |
| 58 | +export default config; |
0 commit comments