I'm trying to have a multiple api test request inside the GET test but the POST request seems not executing.
First the chai get('/api/threads/xx') request returns an array of objects (result.body). I'm trying to make POST test request for each those objects inside the array. It runs the body.forEach part but seems not the POST part.
it('GET', (done) => {
chai.request(server)
.get('/api/threads/xx')
.end((err, result) => {
let body = result.body; // array of objects
body.forEach((elem) => {
it('POST', (innerDone) => {
chai.request(server)
.post('/api/replies/xx')
.send({ text: superb.random(), delete_password: '123', thread_id: elem._id })
.end((err, res) => {
console.log(res);
innerDone();
})
});
})
done();
})
});
Aucun commentaire:
Enregistrer un commentaire