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.
What and where to unit test?
From the course: Node.js: Testing and Code Quality
What and where to unit test?
- [Speaker 1] It's time to start writing unit tests. But what are we going to test? We have a few candidates in the application. The reservation application has a number of custom scripts. App.js is the express application itself. It's less custom code and more of a configuration. The server is located in bin/wwww.js and sets up the HTTP listener. The library directory contains the schema for a reservation which is really standalone. It also has reservations logic and configuration for basic auth. Finally, there are three routes for the admin interface which shows reservations, the static homepage and the reservation form. These are very thin routes, which delegate the work to other libraries. So they're mostly just configuration and a little bit error handling. Out of these, this schema is the best place to start with a unit test. Let's take a look at the file itself. In VS code in the Explorer, open up lib, schema,…
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
-
-
-
-
-
Survey of Node.js testing frameworks5m 5s
-
(Locked)
Install Jest in a Node.js project2m 25s
-
(Locked)
What and where to unit test?4m 46s
-
(Locked)
Writing your first Jest unit test4m 36s
-
(Locked)
Running a test suite with Jest6m 5s
-
(Locked)
Testing asynchronous callbacks with Jest5m 42s
-
(Locked)
Writing callback test suites with Jest6m 32s
-
(Locked)
Testing promises with Jest7m 52s
-
(Locked)
Challenge: Test async/await with Jest49s
-
(Locked)
Solution: Test async/await with Jest2m 51s
-
-
-
-