From 490e6c322d5569711bbaef7bf2201af3e198f4fa Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Tue, 4 Jun 2024 10:40:41 -0400 Subject: [PATCH] Improve jest performance (#9496) Utilizing resources based on thread availability improves performance vs fixed threading. The linked issue for CI crashes has not been closed. Once this is solves, `runInBand` may improves performance in CI. --- .github/workflows/test.yml | 6 ++++-- libs/shared/jest.config.angular.js | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c650d8a62..12649b91ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,10 +48,12 @@ jobs: # Tests in apps/ are typechecked when their app is built, so we just do it here for libs/ # See https://bitwarden.atlassian.net/browse/EC-497 - name: Run typechecking - run: npm run test:types --coverage + run: npm run test:types - name: Run tests - run: npm run test --coverage + # maxWorkers is a workaround for a memory leak that crashes tests in CI: + # https://github.com/facebook/jest/issues/9430#issuecomment-1149882002 + run: npm test -- --coverage --maxWorkers=3 - name: Report test results uses: dorny/test-reporter@eaa763f6ffc21c7a37837f56cd5f9737f27fc6c8 # v1.8.0 diff --git a/libs/shared/jest.config.angular.js b/libs/shared/jest.config.angular.js index 689a04d858..de703e2722 100644 --- a/libs/shared/jest.config.angular.js +++ b/libs/shared/jest.config.angular.js @@ -11,10 +11,8 @@ module.exports = { ".*.type.spec.ts", // ignore type tests (which are checked at compile time and not run by jest) ], - // Workaround for a memory leak that crashes tests in CI: - // https://github.com/facebook/jest/issues/9430#issuecomment-1149882002 - // Also anecdotally improves performance when run locally - maxWorkers: 3, + // Improves on-demand performance, for watches prefer 25%, overridable by setting --maxWorkers + maxWorkers: "50%", transform: { "^.+\\.(ts|js|mjs|svg)$": [