1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-21 11:35:34 +01:00

[EC-497] Fix memory leaks in tests (#3421)

* Add isolatedModules:true

* Add manual typechecking in CI for libs/ tests
This commit is contained in:
Thomas Rittson 2022-09-08 08:05:30 +10:00 committed by GitHub
parent 233c85f7a3
commit 05ebca2c4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 2 deletions

View File

@ -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

View File

@ -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,
},
},
};

View File

@ -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: "<rootDir>/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,
},
},
};