'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); } } },ingrese la descripción de la imagen aquí
Problema Pregunta: según console.log, obtengo la respuesta correcta y espero que res.status sea igual a aprobado y salga del ciclo, pero el problema está aquí, cuando se aprobó y se creó la base de datos en el respaldo, mi el script de prueba aún se ejecuta con el mensaje de error de couchDB (como se muestra en la imagen) en los registros y continúa ejecutando el script a menos que obtenga el error de tiempo de espera. cual es la posible solucion para esto?