Setting karma jasmine DEFAULT_TIMEOUT_INTERVAL globally
Asked Answered
C

1

8

In my Angular app, I use Karma and Jasmine to run my unit tests.

I'd like to change the default timeout interval for async tests, from the 5 seconds default to, let's say, 10 seconds.

I see that you can use jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000 to accomplish it.

However, I'd like to change it globally, via some configuration file. For example in karma.conf.js but I don't see the defaultTimeoutInterval option available.

Caper answered 5/2, 2020 at 15:23 Comment(0)
C
19

I've found the answer in the karma-jasmine GitHub repo.

It looks like the right key is timeoutInterval inside karma.conf.js:

module.exports = function(config) {
  config.set({
    client: {
      jasmine: {
        random: true,
        seed: '4321',
        oneFailurePerSpec: true,
        failFast: true,
        timeoutInterval: 10000 // <- this is what I was looking for
      }
    }
  })
}
Caper answered 5/2, 2020 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.