Hi, 

One team member in our team found the solution.

Problem is that we don't do proper cleaning for global variables in each 
describe block.

Check following link for detailed solution :
 http://stackoverflow.com/questions/32998442/angularjs-unit-testing-memory-leaks

We will try to push this information to AngularJS docs page for writing 
unit tests.

Best regards,
Igor

On Thursday, August 13, 2015 at 6:56:11 PM UTC+2, Robert wrote:
>
> Wondering if you ever found a solution to this problem. I am currently 
> running into the same thing, and looking for tips as well.
>
> Our tests are setup in a similar manner as yours, using the afterEach to 
> try to perform the cleanup & we are at about 3k tests.
>
> Thanks.
>
> On Friday, November 28, 2014 at 3:08:04 AM UTC-5, Igor Bulovski wrote:
>>
>> Hi all, 
>>
>> I want to ask for a guideline or some tips of how to correctly write 
>> large number of unit tests. Currently we have around 1800 tests and that 
>> numbers increases every day. 
>> Majority of the tests are testing directives and services. Some of the 
>> directives renders whole panels and so on.
>>
>> When we run the tests on Chrome , memory goes up to around 850 MB and 
>> they are starting to execute slow and after some period browser is 
>> disconnected.
>> If we switch to Firefox, then test are passing, because Firefox doesn't 
>> have a memory limit per tab (as chrome has), but that is temporary solution.
>> Obviously we have some memory leak or we don't do proper clean up after 
>> the test.
>>
>> About our tests and set up:
>>
>>    - We use :
>>       - angularJS: 1.3.2
>>       - grun-karma: 0.8.2 
>>       - jasmine
>>    - Each test is defined in own file (.spec.js)
>>    - We have general helper file that has :
>>       - beforeEach when we set up some mock for all of the tests.
>>       - afterEach when we try to clean up :
>>          - compiled element with dealoc function (copied from anguilarJS 
>>          source)
>>          - clean $rootScope and $rootElement (also copied from angularJS 
>>          source)
>>          
>> I created small plunker which has non-runnable example of how our test 
>> are structured :
>>  - http://plnkr.co/edit/F8qOdwkaXNJK9ZHhfFEl
>>
>> Currently we are investigating to see why our test take that much of 
>> memory (memory leak). Our application works fine without consuming memory 
>> at all.
>>
>> If anyone had some similar problem or some tips like how to clean up, 
>> what not to use in test (like mock ngModelController) or any idea, please 
>> share to us.
>>
>> Thanks in advance,
>> Igor
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to