I'm building an API and I'm trying to test it with mocha and supertest.
I'm correctly testing a POST call with this code:
it("Should generate a PDF based on the given data using API", function(done) {
request(app)
.post("/api/document/print")
.send({tplName: "default", tplData: { title: "Testee", p1: "paragraph"}})
.expect(200, done);
});
But when I try to test a GET request with this code:
it("Should get HTML of the selected template", function(done) {
request(app)
.get("/api/template/default/html")
.expect(200, done);
});
The test fails, if I run my app and try it in Chrome I get the correct response (200).
What am I doing wrong?