In this example, we clear the items in the application by clicking the delete button on each item. But we have to be careful about writing this test to avoid the default assertions built inside Cypress commands like cy.get.
cy.visit('/').wait(100)
cy.get('.todo')
.should('have.length.gte', 0)
.then(function ($todos) {
if (!$todos.length) {
cy.log('nothing to delete')
return
}
cy.wrap($todos)
.find('.destroy')
.click({ force: true, multiple: true })
})
// confirm there are no items
cy.get('.todo', { timeout: 100 }).should('have.length', 0)
See the full source code in github.com/bah...
18 сен 2024