Search code examples
javascripttypescripttestingcypressgui-testing

The following error originated from your application code, not from Cypress


I tried to test this simple code:

type Url = string
it('loads examples', () => {
    const url: Url = 'https://www.ebay.com/'
    cy.visit(url)
    cy.get('input[type="text"]').type('book')
    cy.get('#gh-btn').click();
})

then I faced this error:

enter image description here

how can I solve it


Solution

  • Try adding this in support/index.js:

    import './commands'
    Cypress.on('uncaught:exception', (err, runnable) => {
      // returning false here prevents Cypress from failing the test
      return false
    })
    

    This should avoid the uncaught:exception in the click() method.