4
votes

we are currently working on an angularjs project with round about 2500 Jasmine test cases. We are using chrome as browser and the karma-ng-html2js-preprocessor to preprocess our templates.

We are now facing the problem that our tests consuming a huge amount of memory and our karma server disconnects, because latter tests are taking way too long. Approximately 2000 tests are executed in 3 mins, but the last 500 are taking up to 10 mins. We tried several solutions we found online to get rid of this problem, but nothing is working. We tried the following solutions:

We analysed the memory usage with the chrome memory snapshot tool. The first snapshot was taken after 300 Tests and the second after 600 Tests.

First Snapshot (300 Tests) Second Snapshot (600 Tests)

Can anybody help with this problem? We are unfortunately not allowed to show some code. But our tests not differ from angular jasmine examples you can find on the web.

1
It's difficult to say without seeing at least your karma config and some tests - the long running ones. I can however tell you when I did experience a similar issue it was because files were being loaded unnecessary and in some cases more than once in my karma config. This caused my karma to crash after a couple thousand tests. - Prinay Panday
Also separation into different modules really helps. If a piece of code does not require a module then do your best to ensure that the module is not loaded for the test. - Prinay Panday

1 Answers

0
votes

Jasmine tests with Angular may generate memory leak if to use variables inside "describe" block but outside "it". Also not cleared html elements can accumulate leak.

Good description: https://developers.google.com/web/updates/2017/04/headless-chrome#frontend