javascriptangularautomated-testskarma-runnerkarma-mocha

Karma closes the browser unexpectly


Hi I am using Karma + mocha to write unit testcases for uicomponents like select, combobox etc...

I am facing a problem where I have about 211 testcases but Karma closes the browser unexpectedly before all the testcases are run. I made sure that methods such as describe.only, describe.some, describe.skip etc.. are not used.

Screenshot of the log when I run the testcases for the first time. second time

Screenshot of the log when I run the same testcases for the second time. first time

I have gone through some Karma code and I found out that from socket.io, "browser_complete" event is emitted and so karma winds up the server. Why is this happening? How can I avoid this problem?


Solution

  • I found the issue myself. done callback was not used for certain asynchronous testcases and since the assertions are included in asynchronous part, the code was not reachable which led to the browser firing complete event that resulted in Karma quitting the browser. But I face this issue even now when testcases fails continuously for which I have not found the solution yet. But the problem I have faced above was due to improper handling of asynchronous test cases.