Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting karma jasmine DEFAULT_TIMEOUT_INTERVAL globally

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.

like image 929
Francesco Borzi Avatar asked Feb 05 '20 15:02

Francesco Borzi


People also ask

What is the default timeout in jasmine for an async test?

It ensures that the test process doesn't get stuck if something goes wrong. By default, the timeout is 10 seconds, which means that a single test should not take longer than that.

What is the default capture time out in karma?

The capture timeout is set to the default value (60000).

How do you increase Jasmine timeout?

To change the timeout on a Jasmine Node async spec, we can set the jasmine. DEFAULT_TIMEOUT_INTERVAL value. describe("long asynchronous specs", () => { let originalTimeout; beforeEach(() => { originalTimeout = jasmine.


1 Answers

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
      }
    }
  })
}
like image 187
Francesco Borzi Avatar answered Sep 28 '22 07:09

Francesco Borzi