0

I want to repeat the operation getRunDetailsStaus() until the status is done. So I put the condition in .then() handler, and I called recursive the funtion next() until the status is DONE. getStatus(runDetailsId) is a promise function that returns the status from mongoDB

See below my step definition:

When('the user waits until receive the status DONE',

    let start = Date.now()

    function getRunDetailsStaus() {
        return getStatus(runDetailsId) //promise function and returns the status from mongoDB
    }

    function next() {
        return getRunDetailsStaus().then(function (result) {

            console.log("status: ", result.runStatus, Date.now() - start)
            if (status == 'DONE') {
                return status
            }
            else {
                return next()
            }
        })

    }

    return next()
        .then((response) => {
            // process final results
        })
        .catch((error) => {
            //process error
        })
});```

But I get the following error: 
function timed out, ensure the promise resolves within 5000 milliseconds


How should I resolve this issue in case the status done in mongo is set in ~30 min?
Raul_M
  • 211
  • 3
  • 11
  • 1
    Possible `cucumber` config? https://stackoverflow.com/questions/45852631/function-timed-out-after-5000-milliseconds-angular-4-protractor-cucumber – daddygames Nov 02 '20 at 15:24
  • thank you for your hint! The problem now is solved! I set the timeout in the step definition: `When('the user {string} waits until receive the status DONE', {timeout: 10 * 10000}, function (user: string) {` – Raul_M Nov 02 '20 at 15:42

0 Answers0