Search code examples
karma-jasminekarma-runnerkarma-coverage

Running Karma with Coverage is failing to shut down Firefox


I am running Karma, Jasmin and Instanbul on Windows 10 and test against ChromeHeadless, FireFoxHeadless and MS-Edge.

The tests all run just fine and the coverage output is written. BUT... Firefox never closes. I get this error: WARN [launcher]: Firefox was not killed in 2000 ms, sending SIGKILL.

  • If I don't test with Firefox, everything works fine.
  • If I don't use coverage, everything works fine.
  • If I make Firefox non-headless then it still fails in the same way
  • If I use JUST Firefox then it still fails in the same way

I have spent over 2 weeks trying to find an answer here on StackOverflow and all over the internet. There were similar problems reported but no one ever had a definitive answer related to Firefox and Coverage.


Solution

  • AWESOME!!!!!!! I figured it out.

    I asked someone a question and their answer got me thinking about timeouts and I changed the following values in my karma.conf.js file and now it is working:

    browserDisconnectTimeout: 10000, browserDisconnectTolerance: 1, processKillTimeout: 100000,

    It seems that the coverage reporting was taking too long and just extending the timeout makes it work fine. The default timeout is 2000ms.

    It seems that something related to Firefox takes longer to write out the Firefox coverage files and that was taking longer than 2000ms. This was leading to the error I was seeing.

    Increasing the timeout allows everything to be written and Firefox to shut down correctly.