I am testing an express API with supertest.
I couldn\'t get multiple requests in a test case to work with supertest. Below is what i tried in a test case. But the test c
This can be most elegantly solved with promises, and there's a really useful library to use promises with supertest: https://www.npmjs.com/package/supertest-as-promised
Their example:
return request(app)
.get("/user")
.expect(200)
.then(function (res) {
return request(app)
.post("/kittens")
.send({ userId: res})
.expect(201);
})
.then(function (res) {
// ...
});