Categories
JavaScript Answers

How to fix jasmine: Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL error with JavaScript?

Spread the love

Sometimes, we want to fix jasmine: Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL error with JavaScript.

In this article, we’ll look at how to fix jasmine: Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL error with JavaScript.

How to fix jasmine: Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL error with JavaScript?

To fix jasmine: Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL error with JavaScript, we should make sure done is called when async code is finished running.

For instance, we write

it("should work", (done) => {
  //...
});

it("should work", () => {
  //...
});

to get the done function in the parameter of the first test.

And we should call it after async code is run in the first test if there’s any.

Conclusion

To fix jasmine: Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL error with JavaScript, we should make sure done is called when async code is finished running.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *