Use Cypress cy.spy() Function to Test a Vue 3 Component’s Emitted Events

InstructorFilip Hric

Share this video with your friends

Send Tweet

emit() function enables components to communicate with one another. While this communication is a good candidate for end to end test, we can also test this in isolation within component. To do this, we’ll use cy.spy() function that will watch for the defined function call. Using this, we can confirm that our emitted event was actually invoked.