Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 3c4fa8b

Browse files
authored
Improve output in github actions for jest tests (#10569)
1 parent 5316bb5 commit 3c4fa8b

File tree

4 files changed

+147
-45
lines changed

4 files changed

+147
-45
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,11 @@ jobs:
5555
id: cpu-cores
5656
uses: SimenB/github-actions-cpu-cores@410541432439795d30db6501fb1d8178eb41e502 # v1
5757

58-
- name: Load metrics reporter
59-
id: metrics
60-
if: github.ref == 'refs/heads/develop'
61-
run: |
62-
echo "extra-reporter='--reporters=<rootDir>/test/slowReporter.js'" >> $GITHUB_OUTPUT
63-
6458
- name: Run tests
6559
run: |
6660
yarn test \
6761
--coverage=${{ env.ENABLE_COVERAGE }} \
6862
--ci \
69-
--reporters github-actions ${{ steps.metrics.outputs.extra-reporter }} \
7063
--max-workers ${{ steps.cpu-cores.outputs.count }} \
7164
--cacheDirectory /tmp/jest_cache
7265

jest.config.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
Copyright 2023 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import { env } from "process";
18+
19+
import type { Config } from "jest";
20+
21+
const config: Config = {
22+
testEnvironment: "jsdom",
23+
testMatch: ["<rootDir>/test/**/*-test.[jt]s?(x)"],
24+
globalSetup: "<rootDir>/test/globalSetup.js",
25+
setupFiles: ["jest-canvas-mock"],
26+
setupFilesAfterEnv: ["<rootDir>/test/setupTests.js"],
27+
moduleNameMapper: {
28+
"\\.(gif|png|ttf|woff2)$": "<rootDir>/__mocks__/imageMock.js",
29+
"\\.svg$": "<rootDir>/__mocks__/svg.js",
30+
"\\$webapp/i18n/languages.json": "<rootDir>/__mocks__/languages.json",
31+
"decoderWorker\\.min\\.js": "<rootDir>/__mocks__/empty.js",
32+
"decoderWorker\\.min\\.wasm": "<rootDir>/__mocks__/empty.js",
33+
"waveWorker\\.min\\.js": "<rootDir>/__mocks__/empty.js",
34+
"workers/(.+)\\.worker\\.ts": "<rootDir>/__mocks__/workerMock.js",
35+
"^!!raw-loader!.*": "jest-raw-loader",
36+
"RecorderWorklet": "<rootDir>/__mocks__/empty.js",
37+
},
38+
transformIgnorePatterns: ["/node_modules/(?!matrix-js-sdk).+$"],
39+
collectCoverageFrom: ["<rootDir>/src/**/*.{js,ts,tsx}"],
40+
coverageReporters: ["text-summary", "lcov"],
41+
testResultsProcessor: "@casualbot/jest-sonar-reporter",
42+
};
43+
44+
// if we're running under GHA, enable the GHA reporter
45+
if (env["GITHUB_ACTIONS"] !== undefined) {
46+
const reporters: Config["reporters"] = [["github-actions", { silent: false }], "summary"];
47+
48+
// if we're running against the develop branch, also enable the slow test reporter
49+
if (env["GITHUB_REF"] == "refs/heads/develop") {
50+
reporters.push("<rootDir>/spec/slowReporter.js");
51+
}
52+
config.reporters = reporters;
53+
}
54+
55+
export default config;

package.json

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -212,44 +212,10 @@
212212
"stylelint": "^15.0.0",
213213
"stylelint-config-standard": "^32.0.0",
214214
"stylelint-scss": "^4.2.0",
215+
"ts-node": "^10.9.1",
215216
"typescript": "5.0.3",
216217
"walk": "^2.3.14"
217218
},
218-
"jest": {
219-
"testEnvironment": "jsdom",
220-
"testMatch": [
221-
"<rootDir>/test/**/*-test.[jt]s?(x)"
222-
],
223-
"globalSetup": "<rootDir>/test/globalSetup.js",
224-
"setupFiles": [
225-
"jest-canvas-mock"
226-
],
227-
"setupFilesAfterEnv": [
228-
"<rootDir>/test/setupTests.js"
229-
],
230-
"moduleNameMapper": {
231-
"\\.(gif|png|ttf|woff2)$": "<rootDir>/__mocks__/imageMock.js",
232-
"\\.svg$": "<rootDir>/__mocks__/svg.js",
233-
"\\$webapp/i18n/languages.json": "<rootDir>/__mocks__/languages.json",
234-
"decoderWorker\\.min\\.js": "<rootDir>/__mocks__/empty.js",
235-
"decoderWorker\\.min\\.wasm": "<rootDir>/__mocks__/empty.js",
236-
"waveWorker\\.min\\.js": "<rootDir>/__mocks__/empty.js",
237-
"workers/(.+)\\.worker\\.ts": "<rootDir>/__mocks__/workerMock.js",
238-
"^!!raw-loader!.*": "jest-raw-loader",
239-
"RecorderWorklet": "<rootDir>/__mocks__/empty.js"
240-
},
241-
"transformIgnorePatterns": [
242-
"/node_modules/(?!matrix-js-sdk).+$"
243-
],
244-
"collectCoverageFrom": [
245-
"<rootDir>/src/**/*.{js,ts,tsx}"
246-
],
247-
"coverageReporters": [
248-
"text-summary",
249-
"lcov"
250-
],
251-
"testResultsProcessor": "@casualbot/jest-sonar-reporter"
252-
},
253219
"@casualbot/jest-sonar-reporter": {
254220
"outputDirectory": "coverage",
255221
"outputName": "jest-sonar-report.xml",

yarn.lock

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,13 @@
11231123
resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9"
11241124
integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==
11251125

1126+
"@cspotcode/source-map-support@^0.8.0":
1127+
version "0.8.1"
1128+
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1"
1129+
integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==
1130+
dependencies:
1131+
"@jridgewell/trace-mapping" "0.3.9"
1132+
11261133
"@csstools/css-parser-algorithms@^2.1.0":
11271134
version "2.1.1"
11281135
resolved "https://registry.yarnpkg.com/@csstools/css-parser-algorithms/-/css-parser-algorithms-2.1.1.tgz#7b62e6412a468a2d1096ed267edd1e4a7fd4a119"
@@ -1474,6 +1481,11 @@
14741481
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78"
14751482
integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==
14761483

1484+
"@jridgewell/resolve-uri@^3.0.3":
1485+
version "3.1.1"
1486+
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721"
1487+
integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==
1488+
14771489
"@jridgewell/set-array@^1.0.1":
14781490
version "1.1.2"
14791491
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72"
@@ -1489,6 +1501,14 @@
14891501
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
14901502
integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==
14911503

1504+
"@jridgewell/[email protected]":
1505+
version "0.3.9"
1506+
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9"
1507+
integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==
1508+
dependencies:
1509+
"@jridgewell/resolve-uri" "^3.0.3"
1510+
"@jridgewell/sourcemap-codec" "^1.4.10"
1511+
14921512
"@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.15", "@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.9":
14931513
version "0.3.18"
14941514
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz#25783b2086daf6ff1dcb53c9249ae480e4dd4cd6"
@@ -1559,7 +1579,6 @@
15591579

15601580
"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz":
15611581
version "3.2.14"
1562-
uid acd96c00a881d0f462e1f97a56c73742c8dbc984
15631582
resolved "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz#acd96c00a881d0f462e1f97a56c73742c8dbc984"
15641583

15651584
"@matrix-org/react-sdk-module-api@^0.0.4":
@@ -2009,6 +2028,26 @@
20092028
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
20102029
integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==
20112030

2031+
"@tsconfig/node10@^1.0.7":
2032+
version "1.0.9"
2033+
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2"
2034+
integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==
2035+
2036+
"@tsconfig/node12@^1.0.7":
2037+
version "1.0.11"
2038+
resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d"
2039+
integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==
2040+
2041+
"@tsconfig/node14@^1.0.0":
2042+
version "1.0.3"
2043+
resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1"
2044+
integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==
2045+
2046+
"@tsconfig/node16@^1.0.2":
2047+
version "1.0.3"
2048+
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e"
2049+
integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==
2050+
20122051
"@types/aria-query@^5.0.1":
20132052
version "5.0.1"
20142053
resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-5.0.1.tgz#3286741fb8f1e1580ac28784add4c7a1d49bdfbc"
@@ -2487,12 +2526,12 @@ acorn-jsx@^5.3.2:
24872526
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
24882527
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==
24892528

2490-
acorn-walk@^8.0.2:
2529+
acorn-walk@^8.0.2, acorn-walk@^8.1.1:
24912530
version "8.2.0"
24922531
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1"
24932532
integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==
24942533

2495-
acorn@^8.1.0, acorn@^8.8.0, acorn@^8.8.1:
2534+
acorn@^8.1.0, acorn@^8.4.1, acorn@^8.8.0, acorn@^8.8.1:
24962535
version "8.8.2"
24972536
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
24982537
integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==
@@ -2605,6 +2644,11 @@ arch@^2.2.0:
26052644
resolved "https://registry.yarnpkg.com/arch/-/arch-2.2.0.tgz#1bc47818f305764f23ab3306b0bfc086c5a29d11"
26062645
integrity sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ==
26072646

2647+
arg@^4.1.0:
2648+
version "4.1.3"
2649+
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
2650+
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
2651+
26082652
argparse@^1.0.7:
26092653
version "1.0.10"
26102654
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
@@ -3375,6 +3419,11 @@ crc-32@^0.3.0:
33753419
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-0.3.0.tgz#6a3d3687f5baec41f7e9b99fe1953a2e5d19775e"
33763420
integrity sha512-kucVIjOmMc1f0tv53BJ/5WIX+MGLcKuoBhnGqQrgKJNqLByb/sVMWfW/Aw6hw0jgcqjJ2pi9E5y32zOIpaUlsA==
33773421

3422+
create-require@^1.1.0:
3423+
version "1.1.1"
3424+
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333"
3425+
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==
3426+
33783427
cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
33793428
version "7.0.3"
33803429
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
@@ -3690,6 +3739,11 @@ diff-sequences@^29.3.1:
36903739
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.4.3.tgz#9314bc1fabe09267ffeca9cbafc457d8499a13f2"
36913740
integrity sha512-ofrBgwpPhCD85kMKtE9RYFFq6OC1A89oW2vvgWZNCwxrUpRUILopY7lsYyMDSjc8g6U6aiO0Qubg6r4Wgt5ZnA==
36923741

3742+
diff@^4.0.1:
3743+
version "4.0.2"
3744+
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
3745+
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
3746+
36933747
dijkstrajs@^1.0.1:
36943748
version "1.0.2"
36953749
resolved "https://registry.yarnpkg.com/dijkstrajs/-/dijkstrajs-1.0.2.tgz#2e48c0d3b825462afe75ab4ad5e829c8ece36257"
@@ -6264,6 +6318,11 @@ make-dir@^3.0.0:
62646318
dependencies:
62656319
semver "^6.0.0"
62666320

6321+
make-error@^1.1.1:
6322+
version "1.3.6"
6323+
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
6324+
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
6325+
62676326
62686327
version "1.0.12"
62696328
resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.12.tgz#3e5dd2079a82e812e983cc6610c4a2cb0eaa801a"
@@ -8181,6 +8240,25 @@ truncate-utf8-bytes@^1.0.0:
81818240
dependencies:
81828241
utf8-byte-length "^1.0.1"
81838242

8243+
ts-node@^10.9.1:
8244+
version "10.9.1"
8245+
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b"
8246+
integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==
8247+
dependencies:
8248+
"@cspotcode/source-map-support" "^0.8.0"
8249+
"@tsconfig/node10" "^1.0.7"
8250+
"@tsconfig/node12" "^1.0.7"
8251+
"@tsconfig/node14" "^1.0.0"
8252+
"@tsconfig/node16" "^1.0.2"
8253+
acorn "^8.4.1"
8254+
acorn-walk "^8.1.1"
8255+
arg "^4.1.0"
8256+
create-require "^1.1.0"
8257+
diff "^4.0.1"
8258+
make-error "^1.1.1"
8259+
v8-compile-cache-lib "^3.0.1"
8260+
yn "3.1.1"
8261+
81848262
tsconfig-paths@^3.14.1:
81858263
version "3.14.2"
81868264
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088"
@@ -8427,6 +8505,11 @@ uuid@9:
84278505
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5"
84288506
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==
84298507

8508+
v8-compile-cache-lib@^3.0.1:
8509+
version "3.0.1"
8510+
resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf"
8511+
integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==
8512+
84308513
v8-compile-cache@^2.3.0:
84318514
version "2.3.0"
84328515
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
@@ -8758,6 +8841,11 @@ yauzl@^2.10.0:
87588841
buffer-crc32 "~0.2.3"
87598842
fd-slicer "~1.1.0"
87608843

8844+
8845+
version "3.1.1"
8846+
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
8847+
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==
8848+
87618849
yocto-queue@^0.1.0:
87628850
version "0.1.0"
87638851
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"

0 commit comments

Comments
 (0)