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
From the course: Node.js: Testing and Code Quality
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Why code coverage matters5m 22s
-
(Locked)
Measuring code coverage with Jest5m 54s
-
(Locked)
Functional testing with Jest4m 1s
-
(Locked)
Test doubles and Express apps5m 53s
-
(Locked)
Form submissions with SuperTest6m 9s
-
(Locked)
Fallacies of 100% test coverage4m 19s
-
(Locked)
Coverage with continuous integration4m 34s
-
(Locked)
Challenge: Isolate routes for faster tests39s
-
(Locked)
Solution: Isolate routes for faster tests9m 27s
-
(Locked)
-