I am getting Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL Error

左心房为你撑大大i 提交于 2021-01-27 18:26:19

问题


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)

回答1:


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

Code:

    jasmineNodeOpts: {
      showColors: true,
      includeStackTrace: true,
      defaultTimeoutInterval: 1440000
     }



回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/41344217/i-am-getting-timeout-async-callback-was-not-invoked-within-timeout-specified-b

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!