Jasmine is a popular JavaScript testing framework, and it now supports async and await calls in tests. This is a big help in cleaning up tests where you previously had to put asserts in a .then() or .catch() callback.

I’ve written before about how you can use Jasmine’s done keyword to test async specs, but here’s a quick recap. You pass in a special Jasmine done parameter, then you invoke the done() function after your async code has completed, usually inside a .then() or a .catch() statement, like this.

See the Pen Testing async code with Jasmine's done by Joe Wilson (@joewilson0) on CodePen.

With version 2.8 and later of Jasmine and your compiler that supports async/await (e.g., Babel, TypeScript), you can change this to be more readable, like this.

See the Pen Testing async code with Jasmine and async/await by Joe Wilson (@joewilson0) on CodePen.

Much cleaner!