vendredi 6 juillet 2018

wait() cannot find previously triggered alias route

Using Cypress js, I have creating end to end tests for a website, and fired the tests in powershell. For some lack of knowledge, aliased routes are not as I expected them to be, when using the wait() function.

core of cypress test issue:

cy.route("http://localhost:8000/admin/portfolio/putstrategy")
    .as("updatetrategy")

cy.get("button")
    .contains("Upload")
    .click()

cy.wait("@updatestrategy")

logs:

enter image description here

I am expecting wait() to match on the request initiated by the button click. What I am getting now is a successful request response, seemingly all before the test can catch up.

From the docs:

Each time we use cy.wait() for an alias, Cypress waits for the next nth matching request.

My understanding of this quote is that wait() will match on the request, who's execution order number matches the waits execution order number, relative to the same address.

Requests can time out and responses can timeout. With this scenario, no request is found matching the wait's number.

How can I use Cypress to wait on a programmatically invoked request?

Aucun commentaire:

Enregistrer un commentaire