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.
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.
The capture timeout is set to the default value (60000).
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.
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
}
}
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With