-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Description
From the examples, I understood that waitUntil will wait until a condition becomes true:
cy.waitUntil(() => cy.getCookie('token').then(cookie => cookie == "some value")));But what if my condition is Cypress assertion? Using the same example:
// what if you need to wait until the cookie 'token' even exists?
cy.waitUntil(() => cy.getCookie('token')));My context is, I have a page that will display data that is being updated by a cron job. The page does not update automatically, so the user must manually refresh the page. Sometimes the cron job takes a little longer, so I want to waitUntil a Cypress command or assertion stops failing. The problem is, as soon as the command fails, the test ends with a failure.
How can I make this code work?
waitUntilPaymentIsProcessed() {
cy.log("Waiting... Payment must be processed by cron job")
cy.waitUntil(
() => {
cy.reload()
cy.get(activePackageSubtitle).should("exist") // wait until this passes
},
{
interval: 3000,
timeout: 10000,
errorMsg: "Timed out waiting for cron to process payment"
}
)
cy.log("Waiting... Done")
}P.S: Thank you so much for writing this lib. It's so useful and so critical. I don't know why it doesn't come out-of-the-box with Cypress. Well done 😄
Metadata
Metadata
Assignees
Labels
No labels