Angular4+karma+jasmine 's UT test causes the browser to crash

Test environment:
1, test environment win7, node v8.9.4 chrome65.0.3325.181 (64-bit) firefox60.0.1 (64-bit) notebook memory 8G
2, large background management system front-end page developed for angular4.4.6. The UT test uses karma1.7.0+jasmine2.6.2. The overall test case of the project is 3480.
phenomenon:
when testing all components, whether starting firefox or chrome, browser memory will increase with the depth of the test, and when the test runs to about 900case, the test stops because of the surge of browser memory, and the restart browser, so that the test starts from scratch, can not complete the entire case test, can not see the overall code coverage.
problem:
1. In order to see the overall coverage, all case tests are necessary, so want to know what causes the browser to restart at a certain time and the memory keeps increasing
2. How to improve the testing techniques, such as through the karma configuration to solve this problem, or optimize the test code to solve (if it is a code problem, What is the general direction of the question)

improvements already used
1, reconfigure karma.config.js files, for example:
(1) do not start using the browser but run with phantomjs, until a certain time will restart and then start to retest
(2) clear the context on the browser, such as clearContext is still set to true,
2, improve the code, add the afterEach method to each test file, clear the global variables, and the problem also occurs

.

after looking at most of the data, we still haven"t found the right way to make the test continue. So I"m going to ask everyone here.

this is also the problem with PS: testing on another mac, which has 16GB of memory for mac. So there are no plans to upgrade the hardware for the time being.


try ChromeHeadless .
configure in karma.config.js: browsers: ['ChromeHeadless']
Headless Chrome is a way to run Chrome browsers in a display-free environment without a browser user interface. One benefit of using Headless Chrome (instead of testing directly in Node) is that JavaScript tests will be performed in the same environment as your site's users. Headless Chrome provides you with a real browser environment without the same memory overhead as running a full version of Chrome.

Menu