Pain is inevitable. Suffering is optional.
― Haruki Murakami, What I Talk About When I Talk About Running
Software Development and Data Consultant
Pain is inevitable. Suffering is optional.
― Haruki Murakami, What I Talk About When I Talk About Running
Very recently I started to use the very nice Karma Test Runner. I really do recommend to check it out.
However I wondered why tests ran very slow sometimes (>20s) and sometimes they where very fast (<1s). Quickly I realised the issue was having the Chrome tab in the background:
The Chrome tab which was connected to Karma was one among others. I used the other tabs for web browsing and development, so the Karma tab wasn’t the active tab. This gives it a very low priority and running tests became extremely sluggish.
This does not happen if the tab is the active on (= you can actually see it). To resolve the issue, simply open a new Chrome window and open the Karma URL there to run the tests. Tests are fast again and if you want to, just minimize this window so it gets out of the way.
Happy coding!
Dallas says
April 21, 2015 at 17:27I had a similar issue. I was running Karma in its own browser window and tab all by itself, but I noticed that my tests where extremely sluggish when I would run them from my Terminal window (in its own desktop space) versus when I would simply refresh the Karma window in Chrome. Apparently the same issue can arise even when the Karma window is in the foreground in its desktop space, but you run the tests from a different space in OS X.
Thank you for this post, it led me right to the issue and now I have speedy tests ( 15 seconds) I was experiencing.
Jean says
July 29, 2015 at 10:13Wououh, cool to finally understand what was the sluggishness source. Thanks a lot.