Skip to content

Commit

Permalink
ci: enable jest --shard option in github-actions (#4545)
Browse files Browse the repository at this point in the history
  • Loading branch information
chimurai committed Aug 29, 2022
1 parent 97dba79 commit 4eed30e
Show file tree
Hide file tree
Showing 4 changed files with 1,297 additions and 1,301 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ jobs:
uses: wagoid/commitlint-github-action@v4

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

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [12.x, 14.x, 16.x, 17.x]
shard: ["1/4", "2/4", "3/4", "4/4"]
webpack-version: [latest]
include:
- node-version: 16.x
Expand Down Expand Up @@ -102,7 +103,7 @@ jobs:
cp -R tmp-client client
- name: Run tests for webpack version ${{ matrix.webpack-version }}
run: npm run test:coverage -- --ci
run: npm run test:coverage -- --ci --shard=${{ matrix.shard }}

- name: Submit coverage data to codecov
uses: codecov/codecov-action@v3
Expand Down
20 changes: 19 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"use strict";

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

0 comments on commit 4eed30e

Please sign in to comment.