I have two question on JS unit testing:
1) Is there some tool that allows to automaticaly run javascript unit tests when certain files are changed (like for example nodemon restarts node.js on js changes).
2) Is this strategy appropriate (efficient) way to run unit tests?
Thanks, Alex
For those who are committed to using nodemon, nodemon -x "npm test"
has worked for me.
nodemon --help
says:
-x, --exec app ........... execute script with "app", ie. -x "python -v".
In our case npm test
is set to run tests by configuring our package.json
For example:
"scripts": {
"test": "mocha"
},
Check out grunt build system and the watch task. You can setup grunt to watch for file changes and then run any tasks you want (test, lint, compile, etc...).
https://github.com/cowboy/grunt
Some of the ideas are covered in this tutorial. http://javascriptplayground.com/blog/2012/04/grunt-js-command-line-tutorial