Quiero poder hacer clic en una casilla de verificación y probar que un elemento ya no está en el DOM en Cypress. ¿Alguien puede sugerir cómo lo haces?
//This is the Test when the check box is clicked and the element is there cy.get('[type="checkbox"]').click(); cy.get('.check-box-sub-text').contains('Some text in this div.')Quiero hacer lo contrario de la prueba anterior. Entonces, cuando hago clic nuevamente, el div con la clase no debería estar en el DOM.
Bueno, esto parece funcionar, así que me dice que tengo algo más que aprender sobre .should()
cy.get('.check-box-sub-text').should('not.exist');también puede buscar un texto que se supone que no existe:
cy.contains('test_invite_member@gmail.com').should('not.exist') Aquí tienes el resultado en Cypress: 0 matched elements
documentación: https://docs.cypress.io/guides/references/assertions.html#Existence
Use .should('not.exist') para afirmar que un elemento no existe en el DOM.
No utilice la afirmación not.visible . Pasaría falsamente en <6.0, pero fallará correctamente ahora:
// for element that was removed from the DOM // assertions below pass in < 6.0, but properly fail in 6.0+ .should('not.be.visible') .should('not.contain', 'Text')Documentos de migración aquí: Migrating-to-Cypress-6-0