0

I want to handle uncaught exceptions occurs while running cypress tests using cucumber.I have to apply the settings before all the feature tests in all modules. How can I handle that?

I tried using the on() function in cypress config, but it is showing me an error

 async setupNodeEvents(on, config) {
      await addCucumberPreprocessorPlugin(on, config);

      on(
        'file:preprocessor',
        createBundler({
          plugins: [createEsbuildPlugin(config)],
        }),
        
      );
 

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

1 Answer 1

0

I would suggest to use the code in a different place, either in cypress/support/e2e.js

// cypress/support/e2e.js
Cypress.on('uncaught:exception', (err, runnable) => {
  return false
})

or inside the step file

// cypress/e2e/step-definition-for-feature-x.ts
import { When, Then } from "@badeball/cypress-cucumber-preprocessor";

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

When('tests while ignoring an uncaught exception', () => {
  ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.