Supertest request expect multiple responses -
i use supertest test http request should return multiple responses. i've been using supertest until case, i've tried:
agent.post("/route/with/multiple/responses") .type('json') .send({some: 'json'}) .expect((res) => { expect(res.status).toequal(200); }) .expect((res) => { expect(res.status).toequal(200); }) .expect((res) => { expect(res.status).toequal(500); cb(); });
this attempt sends post request never gets first "expect" (probably bad syntax on part), tried using supertest-as-promised:
agent.post("/route/with/multiple/responses") .type('json') .send({some: 'json') .expect((res) => { expect(res.status).toequal(200); }) .topromise() .then((res) => { expect(res.status).toequal(200); }) .then((res) => { expect(res.status).toequal(500); cb(); });
this 1 runs through cases 'res' object same object.
i'm stumped, how can supertest test route has multiple responses (is possible)?
Comments
Post a Comment