vendredi 22 novembre 2019

Cypress getByTestId, queryByTestId, findByTestId to check if element doesn't exist

I am trying to check if element doesn't exist in a DOM Tree with Cypress.

If I try to do cy.getByTestId("my-button").should("not.exist") test fails because it couldn't find element.

If I do cy.findByTestId("my-button").should("not.exist") it also fails because of time out.

The test does work if I do either cy.queryByTestId("my-button").should("not.exist") or

cy.get('[data-testid="my-button"]').should("not.exist").

Can someone please explain what's the difference between all 4.

Thanks

Aucun commentaire:

Enregistrer un commentaire