mardi 30 juin 2020

Run all assertions of a test in Cypress

I've a question regarding test structure. The docs clearly state to write tests with multiple assertions instead of multiple tests with single assertions.

But if I want to test if multiple elements are visible the test will fail if the first element was not visible and I therefore have no clue about the other elements. Is there anything I can do to run all assertions?

it("Page should show two actions", () => {
  cy.visit("users/list");
  cy.get("[data-cy=createUser]")
    .should("be.visible")
    .and("have.text", "Create user");
  cy.get("[data-cy=exportUserData]")
    .should("be.visible")
    .and("have.text", "Export data");
});

Aucun commentaire:

Enregistrer un commentaire