Making it easy to run the tests
Now that we have two test suites for the Notes application, how do we easily run them?
One way is to add a test
script to the package.json
file:
"scripts": { "start": "node app", "test": "node test/test-model.js; node test/test-routes-notes.js" },
On Windows this will be a little bit different:
"scripts": { "start": "node app", "test": "node test/test-model.js & node test/test-routes-notes.js" },
Now we can run both suites together, like so:
$ npm test > application-name@0.0.1 test /Users/david/filez/chap09/notes > node test/test-model.js; node test/test-routes-notes.js ····· ✓ OK » 5 honored (1.935s) ··· · ✓ OK » 4 honored (0.004s)
On Windows you might create a batch file, named test.bat
, containing something like this:
node test\test-model.js node test\test-routes-notes.js
Or you could use a Makefile. Put the following into a file named Makefile
:
test: /tmp node test/test-model.js node test/test-routes-notes.js
You, of course...