From the course: JavaScript: Test-Driven Development (ES6)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Testing "Not Found"

Challenge: Testing "Not Found" - JavaScript Tutorial

From the course: JavaScript: Test-Driven Development (ES6)

Start my 1-month free trial

Challenge: Testing "Not Found"

(upbeat music) - [Instructor] So now that we've tested and implemented the success case and the error case for our server endpoint, it's your turn to put some of the techniques you've seen so far into practice. Our server is still missing the functionality for the case where the user with the given user name isn't found, and in this case, what we'll want to do is send back a response with the status code 404 with no response body. So keep in mind that implementing this should involve writing two tests. The first test is going to be in our database wrapper, and we want to make sure that our get user by user name function returns null when a user with a given user name isn't found in the database. So we'll write a test that says that. It returns null when the user is not found. And this'll be an async test, and keep in mind that this test should pass without you having to make any changes to the production code since…

Contents