Reputation: 3128
How could I wait until a variable is initialized in Cypress?
E.g. I have the following code:
let width;
cy.get("[data-cy=foo-bar]")
.should(element => (width = element.width()))
.get("[data-cy=baz-baz]")
//some other chained Cypress operations
...;
I would like the line .getCy("baz-baz")
no to execute until the width
was set. How could I achieve that in the cleanest way you know?
I would like to preserve the chaining of operations and avoid nesting, since I may require more than one variable later on and it becomes quite messy to put everything inside the should
.
Upvotes: 0
Views: 811