'Verify that new database created successfully': async function () {
const request = supertest(syncSuite.list.API_URL);
const random = Math.floor(Math.random() * 30) + 1;
const data = {
'notifyMe': false
};
const createdRes = await request
.post(`${pathapi.create_server}APIDatabase Server${random}`)
.set('Cookie', syncSuite.list.Token, 'Host', syncSuite.list.API_URL,
'Content-Type', 'application/x-www-form-urlencoded')
.send(data)
.expect(200);
createdServer = createdRes.body.name;
let uuid = createdRes.body.uuid;
let attemptsLeft = 50;
const expectedValue = 'passed';
const delayBetweenRequest = 60000;
const check = async () => new Promise((resolve, reject) => {
setTimeout(async () => {
const status_res = await request
.get(`${pathapi.status_path}${uuid}`)
.set('Cookie', syncSuite.list.Token, 'Host', syncSuite.list.API_URL,
'Content-Type', 'application/x-www-form-urlencoded')
.send();
resolve(status_res.body);
}, delayBetweenRequest);
}
);
for (var i = 1; i <= attemptsLeft; i++) {
const res = await check();
console.log("res=============================", res);
if (res.status === expectedValue) {
expect(res.status).to.be.eq(expectedValue);
break;
} else if (i === attemptsLeft) {
expect(false);
}
}
},
Problem Question: as per the console.log i am getting the correct response and waiting for the res.status to be equal to passed and exit the loop but the problem is here, when its passed and DB has been created in the backed, my test script still runs with the couchDB error message(as show in the picture) in the logs and keeps on running the script unless i get the timeout error. what is the possible solution for this?