https://cypress.io logo
Overwrite command to do a followup action?
# i-need-help
l
I need some syntax help. I have a custom command
cy.waitForSpinner()
that waits for the loading animation to disappear (if it exists). I would like to overwrite
cy.click()
to execute this after every click. I've tried a few ways of doing this, but I don't know the proper syntax to make it work. This doesn't work:
Copy code
Cypress.Commands.overwrite('click', (click, ...args) => {
  return click(...args).then(() => cy.waitForSpinner())
})
What's the right way to do this?