I am trying to create a database using the first API call and the second API is getting the status of the created database. can anyone tell why it is not waiting for the status to be passed and marking the test cases to be passed in execution?
'Verify that new database created successfully': async function () {
//const dataStartServer = syncSuite.loginInf.endpoint;
const request = supertest(syncSuite.list.API_URL);
const random = Math.floor(Math.random() * 30) + 1;
const data = {
'notifyMe': false
};
const res = await request
.post(`${pathapi.create_server}DatabaseJ Server${random}`)
.set('Cookie', syncSuite.list.Token, 'Host', syncSuite.list.API_URL,
'Content-Type', 'application/x-www-form-urlencoded')
.send(data);
// .expect(200);
//console.log('Status of server----------------------------', res.body)
let uuid = res.body.uuid;
//let createdServer = res.body.name
let attemptsLeft = 30;
const expectedValue = 'passed';
const delayBetweenRequest = 60000;
async function check() {
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()
// .expect(200);
console.log('log---------------------------', status_res.body.status)
if (status_res.body.status === expectedValue) {
expect(status_res.body.status).to.be.eq(expectedValue)
} else {
attemptsLeft -= 1;
console.log('Status of server----------------------------', status_res.body, attemptsLeft)
if (!attemptsLeft) {
expect(false)
}
else {
setTimeout(check, delayBetweenRequest);
}
}
}`enter code here`
check();
},