I'm trying to test this wrapper to request that I made:// lib/http-client.jsvar app = require('app'),    request = require('request');exports.search = function(searchTerm, next) {  var options = {    url: 'https://api.datamarket.azure.com/Bing/Search/Web',    qs: {      'Query': '\'' + searchTerm + '\'',      'Adult': '\'Off\'',      '$format': 'json',      '$top': 10    },    auth: {      user: app.get('bing identifier'),      pass: app.get('bing identifier')    }  };  request(options, function(err, res, body){    if (err) return next(err);    // TODO: parse JSON and return results  });};where app is an instance of express.  The question is, how do I test the function of this module without having to touch the internet? If I was to do this in other languages I would have mocked the request module but I don't know if that's the best way to do it in node.js.// NODE_PATH=libdescribe('Http Client', function(){  it('should return error if transport failed', function(){    var c = require('http-client'),        results = 'foo';    // request mock should return results when called    c.search('foo', function(err, results){      results.should.eql(res);    });    // TODO  });  it('should return an error if JSON parsing failed', function(){    // TODO  });  it('should return results', function(){    // TODO  });});
Unit testing in node.js and mocking modules
unit testing;node.js