Closed
Description
The behavior of cypress-testing-library's getBy
queries is a bit different than the cypress built-in .get() method: the built-in will retry should('not.exist')
until it times out, but the getBy
queries timeout on the query. One workaround is to change to getBy
to queryBy
, but this requires a little bit of extra dom-testing-library knowledge that can confuse people coming from Cypress, and still doesn't retry.
Alternative
// This doesn't work
cy.getByTestId('my-item').should('not.exist');
// This works for verifying an element isn't present *right now*
cy.queryByTestId('my-item').should('be.null');
// This should retry but does not
cy.queryByTestId('my-item').should('not.exist');
Idea
It might make sense for queryBy*
to actually be aliased to getBy*
in the cypress context?
EDIT: actually the .should() chain should really trigger a retry of the parent command. Maybe custom commands don't hook into .should correctly?
Related to #23, cypress-io/cypress#3109
Metadata
Metadata
Assignees
Labels
No labels