4

Message:

   Error: Timeout - Async callback was not invoked within timeout specified 
   by jasmine.DEFAULT_TIMEOUT_INTERVAL.

  Stack:
     Error: Timeout - Async callback was not invoked within timeout   
      specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
        at ontimeout (timers.js:365:14)
        at tryOnTimeout (timers.js:237:5)
        at Timer.listOnTimeout (timers.js:207:5)
Optimworks
  • 2,537
  • 17
  • 20
Parthi
  • 142
  • 1
  • 1
  • 12

3 Answers3

7

jasmine.DEFAULT_TIMEOUT_INTERVAL is the period of time in milisecs that Jasmine will wait for a single it block before throwing a timeout error.

Timeout error can be a sign that something is wrong in your code or that simply it takes more time run. As stated in another answer, you can either increase the global Jasmine timeout interval or, for a single test, set the timeout like this:

const myTestTimeout: number = 2 * 60 * 1000; //explicitly set for readabilty

it('should validate something', (() => { ...your test code }), myTestTimeout);

My approach would be to increase the timeout for that specific test so that you are sure that the test has enough time (e.g. 3 mins). If the test fails again, you can be pretty sure that the cause of the error is an issue in your code.

Fjut
  • 1,314
  • 12
  • 23
5

Increase the jasmin default time interval. You add below code to conf.js file.

Code:

    jasmineNodeOpts: {
      showColors: true,
      includeStackTrace: true,
      defaultTimeoutInterval: 1440000
     }
Optimworks
  • 2,537
  • 17
  • 20
1

Add this to karma.conf.js

module.exports = function(config) {
  config.set({
    client: {
      jasmine: {
        random: true,
        seed: '4321',
        oneFailurePerSpec: true,
        failFast: true,
        timeoutInterval: 1000
      }
    }
  })
}

Source https://github.com/karma-runner/karma-jasmine#configuration

speksy
  • 700
  • 8
  • 13