Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
Test script still runs with the couchDB error message in the mocha framework for javascript/nodeJS using promises

'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);
            }
        }
    },

enter image description here

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?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda