packages/driver/src/cypress/errorScenarios.md
The various error scenarios Cypress can encounter and how to address them
cy.wrap({ foo: 'foo' })
.should('have.property', 'foo')
.should('equal', 'bar')
//
cy.get('#non-existent') // default assertion
// at root level
foo.bar()
// in test
foo.bar()
// at root or in test
setTimeout(() => {
foo.bar()
}, 20)
cy.wait(10000)
//
cy.wrap({}).should(() => {
foo.bar()
})
//
Cypress.Commands.add('foo', () => {
foo.bar()
})
cy.foo()
// at root
expect(true).to.be.false
// in test
expect(true).to.be.false
//
cy.wrap({}).then(() => {
expect(true).to.be.false
})
//
cy.wrap({}).should(() => {
expect(true).to.be.false
})
async:
cy.viewport() // invalid args
// double visit
cy.visit('/test.html')
cy.visit('https://google.com')
cy.get('div:first').then(($el) => {
$el.hide()
})
.click()
sync:
beforeEach(()=>{
beforeEach(()=>{})
})
expect(true).to.be.nope
cy.visit('/visit_error.html') // error synchronously
cy
.visit('/error_on_click.html')
.get('p').click() // error on click event
cy.visit('/html/visit_error.html') // error asynchronously
cy.visit('/404')
cy.request('http://localhost:12345')