I have an Express server that I am trying to test with SuperTest. The test below does not pass and I'm not sure why.
I see that the response is has a status of 200 (put break-point in the res.status.should.equal(200)
). Why is this test still being marked as a failure my Mocha?
it('Should test invoke user method', function (done) {
supertest(app)
.post('/save/test1/test2/test3')
.expect(200)
.end(function (err, res) {
res.status.should.equal(200);
done();
});
});
You should have the output that tells you exactly what you received.
You can also test manually with https://www.getpostman.com/ (now they're on mainenance but it should by up again soon), that helps A LOT in development, if you're doing api tests you could also be intrested in https://github.com/apiaryio/dredd, that changed entirely my workflow
edit:
Postman: a rest client which is a chrome/FF plugin, you can use it to make the call and easly see what the response is like (you can use curl and wget but postman is easy esepecially when you need to play with the header)
Dredd: a tool which in theory validates your blueprints/documentation to see if that is in sync with your server, in reality you can do a red-green light development having first all your blueprints for the api and then make all the tests pass, the goods about that is that you can actually see what is the json/anything else that is responded from server and how it differs from your code