I\'m in the process of learning Node.js and have been playing around with Express. Really like the framework;however, I\'m having trouble figuring out how to write a unit/i
The easiest way to test HTTP with express is to steal TJ's http helper
I personally use his helper
it("should do something", function (done) {
request(app())
.get('/session/new')
.expect('GET', done)
})
If you want to specifically test your routes object, then pass in correct mocks
describe("Default Route", function(){
it("should provide the a title and the index view name", function(done){
routes.index({}, {
render: function (viewName) {
viewName.should.equal("index")
done()
}
})
})
})