1611 shaares
17 private links
17 private links
2 results
tagged
routes
As others have recommended in comments, it looks like the canonical way to test Express controllers is through supertest.
An example test might look like this:
describe('GET /users', function(){
it('respond with json', function(done){
request(app)
.get('/users')
.set('Accept', 'application/json')
.expect(200)
.end(function(err, res){
if (err) return done(err);
done()
});
})
});
Upside: you can test your entire stack in one go.
Downside: it feels and acts a bit like integration testing.