Skip to content

Instantly share code, notes, and snippets.

@roamingthings
Created November 29, 2019 09:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roamingthings/a439b0cfde5bc17945d55a5bbf2a215e to your computer and use it in GitHub Desktop.
Save roamingthings/a439b0cfde5bc17945d55a5bbf2a215e to your computer and use it in GitHub Desktop.
Chain of requests using Supertest.js
describe('Chain calls to an api', () => {
it('should perform all requests subsequentially', done => {
request(app)
.get('/api/first')
.expect(200)
.end((err: any, res: Response) => {
if (err) return done(err);
const action = res.text
request(app).get('/api/second')
.query({ action })
.expect(200)
.end((err: any, res: Response) => {
if (err) return done(err);
request(app).get('/api/third')
.expect(200)
.end(done);
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment