Skip to content

Commit 4eed30e

Browse files
authored
ci: enable jest --shard option in github-actions (#4545)
1 parent 97dba79 commit 4eed30e

File tree

4 files changed

+1297
-1301
lines changed

4 files changed

+1297
-1301
lines changed

Diff for: .github/workflows/nodejs.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ jobs:
5959
uses: wagoid/commitlint-github-action@v4
6060

6161
test:
62-
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }}
62+
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }} (${{ matrix.shard }})
6363

6464
strategy:
6565
matrix:
6666
os: [ubuntu-latest, windows-latest, macos-latest]
6767
node-version: [12.x, 14.x, 16.x, 17.x]
68+
shard: ["1/4", "2/4", "3/4", "4/4"]
6869
webpack-version: [latest]
6970
include:
7071
- node-version: 16.x
@@ -102,7 +103,7 @@ jobs:
102103
cp -R tmp-client client
103104
104105
- name: Run tests for webpack version ${{ matrix.webpack-version }}
105-
run: npm run test:coverage -- --ci
106+
run: npm run test:coverage -- --ci --shard=${{ matrix.shard }}
106107

107108
- name: Submit coverage data to codecov
108109
uses: codecov/codecov-action@v3

Diff for: jest.config.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"use strict";
22

33
module.exports = {
4-
testURL: "http://localhost/",
4+
testEnvironmentOptions: {
5+
url: "http://localhost/",
6+
},
57
collectCoverage: false,
68
coveragePathIgnorePatterns: [
79
"/node_modules/",
@@ -12,4 +14,20 @@ module.exports = {
1214
snapshotResolver: "<rootDir>/test/helpers/snapshotResolver.js",
1315
setupFilesAfterEnv: ["<rootDir>/scripts/setupTest.js"],
1416
globalSetup: "<rootDir>/scripts/globalSetupTest.js",
17+
moduleNameMapper: {
18+
// This forces Jest/jest-environment-jsdom to use a Node+CommonJS version of uuid, not a Browser+ESM one
19+
// See https://github.com/uuidjs/uuid/pull/616
20+
//
21+
// WARNING: if your dependency tree has multiple paths leading to uuid, this will force all of them to resolve to
22+
// whichever one happens to be hoisted to your root node_modules folder. This makes it much more dangerous
23+
// to consume future uuid upgrades. Consider using a custom resolver instead of moduleNameMapper.
24+
//
25+
// More:
26+
// https://jestjs.io/docs/upgrading-to-jest28#packagejson-exports
27+
// https://github.com/microsoft/accessibility-insights-web/pull/5421#issuecomment-1109168149
28+
//
29+
// FIXME: this uuid moduleNameMapper workaround can be removed after sockjs > uuid@v9 release
30+
// https://github.com/uuidjs/uuid/pull/616#issuecomment-1206283882
31+
"^uuid$": require.resolve("uuid"),
32+
},
1533
};

0 commit comments

Comments
 (0)