1

What I'm trying to do here is simple : I have and filter method called "search()" that is called on different action on my page.

I'd like to "spy" this method and then check if it was called with : cy.get('method').should('be.called')

But really, I don't understand how to reach the method, that is written in one of my component as vue method and spy on it. I've read the docs, but still can't understand how to do this.

Thanks in advance.

Jérome BORGA
  • 555
  • 1
  • 3
  • 12
  • Have you created the [spy](https://docs.cypress.io/api/commands/spy#Method) before the method is called, perform the action to call the method, then check it is called? – jjhelguero Feb 08 '22 at 23:09
  • Well I did write cy.spy(object, 'method'), but what is this object before my method ? Why do I have to wrap m method inside this object, as documentation says ? – Jérome BORGA Feb 09 '22 at 09:25

1 Answers1

0

This did the trick for me:

mount(Component, opts)
cy.spy(Component.methods, 'method').as('method')
cy.get('@method').should('have.been.calledOnce')