Skip to content

ci: enable jest --shard option in github-actions #4545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"),
},
};
Loading