Loading

Our next test will be really similar to the first. This time we want to handle the case where a response has already been sent which you know if the res.headersSent property is set. So we’ll add that property to our fake response object and verify the middleware behaves correctly.

Transcript

Write a Unit Test for Handling headersSent in an Error Middleware