Cypress says
So we can't change the subject behavior when overwriting a command, and We can't add a new command with the same name as a core command (link).
How can I create a find
command with my own custom behavior and an optional subject.
(Note: I would take a different name, but I guess find
and get
are the most readable and are already part of the Cypress)
// this is just an example of a custom find
Cypress.Commands.overwrite('find', (originalFn, selector, options) => {
return cy.log('my custom find')
})
cy.get('body').find('div') // OK
cy.find('div') // throws ERROR (I want this to be possible)