April 2018
Intermediate to advanced
178 pages
3h 51m
English
Have you noted that the app.js express application created with express-generator is actually a node.js module exporting the express instance? In case you have, you must have asked yourself why that is actually needed. Well, having the express instance exported as a module enables it to be unit-tested. We already utilized the mocha framework in Chapter 4, Using NoSQL Databases, where we developed a unit test for the CatalogItem module. We will use mocha once again and wrap a unit test around each operation API exposes. To unit-test the express application, we will need to do the following: