Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!