Loading
Current section: Testing Asynchronous Code 5 exercises
Problem

Error Assertions for Rejected Promises

Transcript

00:00 To make a greetByResponse function more robust, we're adding a check here for the cases when the response is not provided, we will throw an error letting whoever is using this function know that they're forgetting to pass in the response. Now let's write an automated test just for this scenario.

00:15 The thing is, if we just await the greetByResponse function, that won't do us any good, because in this circumstance, the promise is expected to reject. The task in this exercise will be to modify the existing expect function so it can accept

00:30 a promise that's still pending, and then give you back this nice chaining of rejects.toThrow to help you assert on the exact error message used to reject that promise. That sounds like a fun exercise, isn't it?