mardi 2 février 2021

Check for approximate attribute value in cypress test

I have written the following Cypress test to test an SVG element in my Angular app:

it("should have the right size", () => {
  cy.get(".rectangle")
    .first()
    .and("have.attr", "width", "80")
    .and("have.attr", "height", "60");
});

Unfortunately, the value of width and height can slightly vary. So I should rather allow for some small deviation.

What is the recommended, shortest and/or most elegant way to do that?

Aucun commentaire:

Enregistrer un commentaire