https://cypress.io logo
Heyo, I was wondering if there's a nice way to do ...
# help
t
Heyo, I was wondering if there's a nice way to do this in Cypress, but haven't found a solution to conditionally check it: 1. If an element exists, wait for it to disappear (this works, code example below) 2. if the same element is not found initially, DO NOT wait for its existence on the first place and skip point 1
Copy code
Cypress.Commands.add("checkWaitNoSkeletonLoaders", (timeout = undefined) => {
  cy.get(
.react-loading-skeleton`, { timeout }).then(($elements) => { if ($elements.length < 1) return true; cy.wrap($elements, { timeout }).each(($el) => { cy.wrap($el, { timeout }).should("not.exist"); }); }); });` Why I would need point 2 at the same time? Because on CI for some weird reason some tests fail at this command (timeout waiting for the element). When running locally but using the same url where our CI tests, it always passes.