Writing test cases

First up, inside the Terminal, we're going to install, using npm install, two modules. We need Expect, which is our assertion library, @1.20.2, and mocha to run our test suite at version 5.0.5. We'll then use the --save-dev flag to add these as development dependencies:

npm install expect@1.20.2 mocha@5.0.5 --save-dev

Let's go ahead and run this command, and once it's done we can move into package.json and set up those test scripts.

They're going to be identical to the ones we used in the last project in the previous chapter.

Inside package.json we now have our two dev dependencies, and inside the scripts we can get started by removing the old test script. We'll add those two scripts, test and test-watch:

"scripts": {

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.