This is one thing that I love about Node.js/Javascript, doing this sort of thing is simple once you got the hang of it.
In short, you run your server code and then actually use either Request or Superagent to make these HTTP requests. I personally prefer Superagent because of it's automatic JSON encoding, but be careful, the docs are out of date and incorrect, YMMV. Most people choose Request.
Simple Mocha Example using Request:
describe('My Server', function(){
describe('GET /users', function(){
it("should respond with a list of users", function(done){
request('http://mytesturl.com/users', function(err,resp,body){
assert(!err);
myuserlist = JSON.parse(body);
assert(myuserlist.length, 12);
done();
});
});
});
});
Hopefully that helps. Here is a sample of my Mocha (CoffeeScript) testing using this style with complete detailed examples: https://github.com/jprichardson/logmeup-server/blob/develop/test/integration/app.test.coffee Oh ya, it also is using Superagent.