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?

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,…

Contents