From the course: Node.js: Testing and Code Quality

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Challenge: Mock a successful reservation creation

Challenge: Mock a successful reservation creation

From the course: Node.js: Testing and Code Quality

Challenge: Mock a successful reservation creation

(upbeat music) - [Instructor] In this chapter we learned about a number of different techniques for replacing and inspecting our code with Jest mocks. In lib/reservations.test.js we've tested creating a reservation in two different ways. But both have been testing what happens when validation fails. Your challenge is to update reservations.test.js and add a new test spec for successfully creating a reservation in the database. Of course, the test won't interact with the actual database so you'll have to mock that up. As a stretch goal also mock the validation in order to skip it as validation is tested elsewhere. When you're done check out one possible solution in the next video, see you in a moment.

Contents