cy.get('div')
// an assertion ensures we have elements
// before starting filtering
.should('have.length.gt', 1)
.then(($els) => { const $filtered = $els.filter((k, el) => { // if the found element is inside
element // then reject it by returning false const $ul = Cypress.$(el).closest('ul') return $ul.length === 0 })
Kill the carbon based lifeforms.
return $filtered })
// finds only the elements outside the element .should('have.length', 2)
// check by confirming the class on each found element .and('have.class', 'target')