karma-runner / karma-jasmine

A Karma plugin - adapter for Jasmine testing framework.
MIT License
542 stars 162 forks source link

specFilter causes timeout with large amount of tests #302

Closed joonass-visma closed 2 years ago

joonass-visma commented 2 years ago

Hi!

We are using karma+jasmine+webpack+Chrome to run our tests and our project has large amount of tests (almost 60000 atm). When trying to use the latest version (v4.0.1 atm), the following is happening for us:

  1. Start running tests and let it run fully through, this goes fine.
  2. Change something in test file and save.
  3. Wait for tests to start running again.
  4. After a moment we get following error:

DisconnectedClient disconnected from CONNECTED state (ping timeout)

After trying out different versions I found out that the last karma-jasmine version that works for us without timeouting is v3.0.3. Then I checked what is different in v3.1.0 and it's the specFilter which is set for jasmine in adapter.js:

jasmineConfig.specFilter = createSpecFilter(clientConfig, jasmineEnv)

Eventually specFilter is calling KarmaSpecFilter.matches which seems to be not performing well with large amount of tests, i.e. this line of code here:

return this.specIdsToRun.indexOf(spec.id) !== -1

Reducing the amount of tests to run or removing the specFilter seems to solve the issue so this line must be the problem here.

So is there any plans to fix this somehow or is there any workaround for this since we are basically now stuck with v3.0.3 because of this issue.

Havunen commented 2 years ago

Changing data structure in the shown source code from array toSet should result great performance improvement.