I want to be able to click on a check box and test that an element is no longer in the DOM in Cypress. Can someone suggest how you do it?
//This is the Test
According to https://docs.cypress.io/guides/references/assertions.html#Existence
// retry until loading spinner no longer exists
cy.get('#loading').should('not.exist')
This works for the case that it is being removed. but in the case that you want it to never exist... docs.cypress.io/guides/references/assertions.html#Existence It will retry until it goes away. This doesn't really work for the title problem which is what most people will be looking for.
However if you want to test that the thing never exists in our case.
// Goes through all the like elements, and says this object doesn't exist ever
cy.get(`img[src]`)
.then(($imageSection) => {
$imageSection.map((x, i) => {
expect($imageSection[x].getAttribute('src')).to.not.equal(`${Cypress.config().baseUrl}/assets/images/imageName.jpg`);
});
})