dimanche 30 juin 2019

How to use .should with the "closeTo" assertion in Cypress?

In this SO post, the following code snippet was posted.

cy.window().then(($window) => {
  expect($window.scrollY).to.be.closeTo(400, 100);
});

However, I would like to use the "should" syntax as shown below.

// This code works
cy.window().its('scrollY').should('equal', 400);

How can I use "should" and "closeTo" together in Cypress (the following does not work)?

// This code doesn't work
cy.window().its('scrollY').should('closeTo', 400, 100);

The documentation doesn't seem to show an example for the above case.

Aucun commentaire:

Enregistrer un commentaire