Created
November 29, 2019 09:04
-
-
Save roamingthings/a439b0cfde5bc17945d55a5bbf2a215e to your computer and use it in GitHub Desktop.
Chain of requests using Supertest.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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