Overloaded test suits

It is important not to add new unit tests if a test suite already exceeds a very high memory limit. It is optimal that the memory used by a test suit is within the range of 1500 mb to 1600 mb, this data can be verified in the terminal after executing the tests of some suite.

It is recommended to create and configure another spec.ts file in order to add new unit tests.

How to check memory values by test suite

In order to get heap memory values on Jest, the logHeapUsage flag is used. This flag allows to log the memory values when running the unit tests. In addition, to look for memory leaks it runs along with runInBand flag. Here is an example of the instruction to run the unit tests:

// LogHeapUsage
"test":  "node --expose-gc --max-old-space-size=1500 ./node_modules/jest/bin/jest --config ./jest.config.js --coverage --max-workers=3 --logHeapUsage --silent",

// To look for memory leaks
"test-heap":  "node --expose-gc ./node_modules/jest/bin/jest --config ./jest.config.js --coverage --runInBand --logHeapUsage --silent",

// To inspect memory with Chrome DevTools with flag --inspect-brk
"test-leak-inspect":  "node --inspect-brk --expose-gc ./node_modules/jest/bin/jest --config ./jest.config.js --coverage --runInBand --logHeapUsage --silent",

These scripts are already located on package.json of each of the frameworks repositories.

If using Jest Runner --logHeapUsage flag can be added through settings. That can be found on Jest Runner section.

Last updated