Book Image

Node Web Development - Second Edition

By : David Herron
Book Image

Node Web Development - Second Edition

By: David Herron

Overview of this book

Table of Contents (17 chapters)
Node Web Development Second Edition
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

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

> [email protected] 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...