Test Promises Using Async and Await
Learn to test Promises using async and await.
In everyday work, we often need to deal with Promises (MDN article). Jasmine allows for a straightforward way of testing these using async
and await
(MDN article)
The ArticleDelete
class
What follows is a very simplified example of a class that handles deleting articles in a browser application. It accepts some input and makes a request to a server API if conditions are met.
For this lesson, the
ArticleAPI
methods are considered returning instances ofPromise
. So, thedelete
method returns aPromise
.
Run the code playground below and see the breakdown below.
Get hands-on with 1400+ tech skills courses.