Skip to content

Instantly share code, notes, and snippets.

@Ebazhanov
Created August 3, 2021 07:09
Show Gist options
  • Save Ebazhanov/9afbcb3630611db0d24a6ed613a283e4 to your computer and use it in GitHub Desktop.
Save Ebazhanov/9afbcb3630611db0d24a6ed613a283e4 to your computer and use it in GitHub Desktop.
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
/**
* Ignore uncaught exceptions
* https://docs.cypress.io/api/events/catalog-of-events#App-Events
*/
Cypress.Commands.add('ignoreUncaughtException', () => {
Cypress.on('uncaught:exception', (err) => {
// returning false here prevents Cypress from
// failing the test
return false;
});
});
declare global {
namespace Cypress {
interface Chainable<Subject> {
ignoreUncaughtException(): Chainable<any>;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment