dimanche 31 janvier 2021

How to get cypress to return children length of 0 when there isnt any children

So I am writing a test that will add a card to a container(payment-card-container) and I want to confirm an element was added later by seeing if the children have increased by 1. But I am having issues when we try to count the children length when there isnt any. I am currently using the below:

cy.get('[data-test-id="payment-card-container"]')
    .children()
    .its('length')
    .then(length => {
        const childrenLength = length;
    })

But Cypress seems to get an error because it cant find the children (Error below).

Timed out retrying: Expected to find element: ``, but never found it.

Is there a way this can work when there isnt any children and it returns the value of 0?

Aucun commentaire:

Enregistrer un commentaire