cypress-component-testing-examples icon indicating copy to clipboard operation
cypress-component-testing-examples copied to clipboard

Fixing Vue 2 + Vuetify project by adding custom mount command

Open JessicaSachs opened this issue 3 years ago • 0 comments

👋🏻 the solution for projects that have global plugins for Vue 2 is to create a wrapper component. You'll also notice that the usage of .vue() to get the emitted events is unnecessary and I would discourage that pattern in favor of using cy.spy().as('myFunctionAlias') and asserting the spy was called.

cy.mount(MyComponent, { listeners: { 'action-btn:clicked': cy.spy().as('onActionButtonClicked') } } )
  .get('button').click()
  .get('@onActionButtonClicked').should('have.been.called')

JessicaSachs avatar Jan 25 '22 20:01 JessicaSachs