I'm trying a TDD approach using Mocha and SuperAgent, but got stuck when the res.text from SuperAgent is somehow undefined.
Test:
it('should return 2 given the url /add/1/1', function(done) {
request
.get('/add/1/1')
.end(function(res) {
res.text.should.equal('the sum is 2');
done();
});
});
Code:
router.get('/add/:first/:second', function(req, res) {
var sum = req.params.first + req.params.second;
res.send(200, 'the sum is ' + sum);
});