Configuring and running tests

We have more tests to write, but let's first get set up to run the tests. The simplest model to test is the in-memory model. Let's add this to the scripts section of notes/test/package.json:

"test-notes-memory": "NOTES_MODEL=memory mocha test-model",

To install dependencies, we must run npm install in both the notes/test and notes directories. That way both the dependencies for the test code, and the dependencies for Notes, are installed in their correct place.

Then, we can run it as follows:

$ npm run test-notes-memory> notes-test@1.0.0 test-notes-memory /Users/david/chap11/notes/test> NOTES_MODEL=memory mocha test-model  Model Test    check keylist      √ should have three entries      √ should have keys n1 n2 n3 √ should ...

Get Node.js Web Development - Fourth Edition 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.