Karma tests reporting fast runs, but actually running slow

1.9k Views Asked by At

This is best explained with a video (or see the gif below):

execution example

You'll notice that the Karma progress reporter is reporting that the tests are taking milliseconds, but it's obviously taking quite a while...

I tweeted about this and was told to

Try opening the debug page, and open the devtools to generate timings that should show you where the slow down happens

So here's a video of that. I'm not sure what they mean by "generate timings..."

Sometimes my karma tests run very quickly as I would expect (and as it's reported). Sometimes it runs really slow, but it says it's running in milliseconds. This can happen even if I use describe.only on a small handful of tests (but again, not all the time). I think this happens more often the longer I have the tests running (the watcher).

I'm using angular, webpack, es6 (with babel), karma, mocha, chai, and sinon.

I notice that even if I build my tests without the karma-webpack plugin and then run karma on the result, I still see this problem (so I don't think it's the karma-webpack plugin).

The videos above are my test suite for my work project (we're working on coverage...). But I notice this same problem sometimes in my open source project angular-formly which is built and tested in much the same way. It's a much smaller codebase (around 2k lines compared to 30k lines).

So, my question is, why is it reporting that it's running super fast, but not actually running super fast and how can I make it run fast?

1

There are 1 best solutions below

0
On BEST ANSWER

Edit: This seems to no longer be an issue. You should be fine to use Chrome these days.

The problem is similar to this issue. However, it looks like Chrome needs to be in the foreground (maybe a recent change?)... I don't see the problem in Firefox.

So, the solution is to use Firefox instead.

However, if Chrome needs to be used specifically, you can read another question I posted to address getting around this issue.