I'm trying to achieve something similar to Cypress request with retry - although comments on that post suggest the solution no longer works / never did work?!
Anyway, I need to send a request to an elastic server, and if no records are returned, wait a bit, then try again (retrying every few (10) seconds, up to say, 2 mins of retries at most)... ie something like:
cy.request({auth,method,body,url...}).then(reqresult => {
if (reqresult.body.hits.hits.length){
// results are in elastic, return them
}
else {
cy.wait(10000)
// repeat the request, if retry attempts not exceeded, or return the empty response if exceeded
}
})
But everything I've tried (including similar to the post above) has either produced the "mixing async with sync" error, or has simply looped without resending the request, or at worst, has caused my Cypress (10.3.0) window to hang completely!
Can anyone offer any help please?