Joined July 2012

Forbes Lindesay

Cambridge, UK

Posted to Auto-run tests in Node.js over 1 year ago

Your package.json could be written as:

"scripts": {
  "autotest": "supervisor -q -n exit -x mocha -- -b"
"devDependencies": {
  "mocha": "~1.10.0",
  "supervisor": "~0.5.2"

and would behave the same because npm is super clever

I'd recommend something like Q because it's compatible with ES6 generators. That means that once the next version of JS comes out you'll be able to write code like:

spawn(function* () {
  var result = yield webRequestAsync('');
  //Do something with result

which looks just like the sync equivalent, except for the yield keyword. It would then be exactly equivalent to:

function () {
  return webRequestAsync('')
    .then(function (result) {
      //Do something with result

Consider that yield also works perfectly inside try catch statements etc. and you're onto a winner.

122 Karma
907 Total ProTip Views