I want to test create, findById, and GetList that express api.
And I want to call create api repeatedly for test getlist function.
But If I use for loop syntax, that occurred TCPWRAP error.
How can I call the api repeatedly in supertest?
test("Make Some Products (10)", (done)=> {
for(let i=0;i<10;i++) {
agent
.post(`/api/product`)
.send({
...productJson,
title: productJson.title + String(i),
})
.expect(200)
.end((err, res) => {
if(err) throw err;
expect(res.body.success).toBeTruthy();
productIds.push(PRODUCT_ID);
});
}
done();
});