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

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Form submissions with SuperTest

Form submissions with SuperTest

- [Instructor] The page for reservations has a form, so let's functionally test that next. Switch back to VS Code and make sure that route reservations.test.js is open. Navigate to after the GET and describe a POST group. The first test we can do is see what happens if a reservation request is invalid. It should reject an invalid reservation request, then an async arrow function expression. Similar to GET, we'll create a response. So const response, then await app.post, the http verb that we're going to use to the /reservations endpoint. On the next line, let's specify the type of request explicitly. This is a form. Other options include JSON. This time, we're going to be sending information in the form of an object, which will be automatically encoded to a form submission. We're going to set the date to 2017/06/10, the time to 06:02 am, the party, we're going to set this to something invalid, so bananas, then the…

Contents