Search code examples
javascriptautomationautomated-testslocalhostcypress

Unable to load localhost URL in Cypress.io


I am facing an issue in Cypress.io, when I load local URL it gives an error every time. I have even added the { "baseUrl": "http://localhost:4200" } in cypress.json file as mentioned in the official documentation.

Following are my couple of test scripts:

it('successfully loads', () => {
  cy.visit('http://localhost:4200/') // change URL to match your dev URL
})
it('successfully load', () => {
    cy.visit('/') // change URL to match your dev URL
})

enter image description here


Solution

  • I am not sure why the error occurs in this case, but if you just need to turn it off - you can add this line under your cy.visit call. The error should not occur again.

    Cypress.on('uncaught:exception', (err, runnable) => { return false; })