Skip to content

How to test disappearance? #13

Closed
Closed
@pr0da

Description

@pr0da
  • cypress-testing-library version: 2.2.0
  • node version: 9.4.0
  • yarn version: 1.7.0

Relevant code or config

// I have a table with users, and I want to test user deletion
cy.getByTestId(`user-id-${userId}`).within(() => {
  cy.getByText('Remove').click();
});
cy.getByTestId(`user-id-${userId}`).should('not.exist');

What you did:
I've tried to use cypress-testing-library custom commands with should('not.exist') expectation.

What happened:
The expectation failed, because cypress does not wait until the row/element disappeared.

On the other hand the following works as expected:

cy.getByTestId(`user-id-${invitee.userId}`).within(() => {
  cy.getByText('Remove').click();
});
cy.get(`[data-testid="user-id-${invitee.userId}"`).should('not.exist');

What would be the proper way to test element disappearance with custom commands?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededneeds discussionWe're not sure what to do about this and need to discuss it further.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions