Select Page

Testing Q Promises in Node.js

Technorati Tags: node.js,testing The code Let’s say you have a Node module (named potentialPartner.js) that returns a promise, as such: var Q = require("q"); function willYouLoveMe(cond){ var deferred = Q.defer(); if (cond === "even if I were out of...

Node.js module testing via rewire

When testing Node modules, one of the challenges you face is dealing with other module dependencies (either third-party modules or your own ones). Let’s say you want to test this module: var electricSaw = require("./electricSaw"), table = { wood: {} };...