0

uncaught exception I found below answer is solving the problem but as you know we no longer have support/index.js file with Cypress version 10 and higher.

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

How can I use this block of code with Cypress version 10 and higher. Potentially in my cypress.config.js file to solve uncaught exception error?

2 Answers2

0

With Cypress 10+, the support file now lives in either cypress/support/e2e.js (for e2e tests) or cypress/support/component.js (for component tests). You should be able to add that code block to the relevant support file and achieve the same result as Cypress 9 and below.

agoff
  • 5,818
  • 1
  • 7
  • 20
0

For Cypress version 10 and above, you can add the exception in support>e2e.js to handle it globally for all the spec files.

Anshita
  • 3
  • 3
  • Welcome to SO! Please take a look at the other answers that were given before. Your approach is mentioned there already. In order to keep the site clear and make it easy to find answers, we try to avoid double answers. – ahuemmer Jan 03 '23 at 11:32