diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 36e4157f05..bb0b4453df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,16 @@ jobs: - name: Install Node dependencies run: npm ci + # We use isolatedModules: true which disables typechecking in tests + # 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: | + for p in libs/**/tsconfig.spec.json; do + echo "Typechecking $p" + npx tsc --noEmit --project $p + done + - name: Run tests run: | - export NODE_OPTIONS=--max_old_space_size=6144 npm run test diff --git a/jest.config.js b/jest.config.js index e8f4ce151d..7a747974f5 100644 --- a/jest.config.js +++ b/jest.config.js @@ -26,4 +26,13 @@ module.exports = { // https://github.com/facebook/jest/issues/9430#issuecomment-1149882002 // Also anecdotally improves performance when run locally maxWorkers: 3, + globals: { + "ts-jest": { + // Further workaround for memory leak, recommended here: + // https://github.com/kulshekhar/ts-jest/issues/1967#issuecomment-697494014 + // Makes tests run faster and reduces size/rate of leak, but loses typechecking on test code + // See https://bitwarden.atlassian.net/browse/EC-497 for more info + isolatedModules: true, + }, + }, }; diff --git a/libs/shared/jest.config.base.js b/libs/shared/jest.config.base.js index 7538064c28..056e54e9a7 100644 --- a/libs/shared/jest.config.base.js +++ b/libs/shared/jest.config.base.js @@ -10,10 +10,15 @@ module.exports = { // Also anecdotally improves performance when run locally maxWorkers: 3, - // Jest does not use tsconfig.spec.json by default globals: { "ts-jest": { + // Jest does not use tsconfig.spec.json by default tsconfig: "/tsconfig.spec.json", + // Further workaround for memory leak, recommended here: + // https://github.com/kulshekhar/ts-jest/issues/1967#issuecomment-697494014 + // Makes tests run faster and reduces size/rate of leak, but loses typechecking on test code + // See https://bitwarden.atlassian.net/browse/EC-497 for more info + isolatedModules: true, }, }, };