Using Spies

Learn how to use spies for Cypress component testing.

In our end-to-end tests, we verified that certain functionalities worked, such as creating a new meetup and asserting that a new meetup is inserted into the database after submitting a form. This works well when we intend to test the frontend, the backend, and the database simultaneously. In component tests, we don’t have access to these other services, so we can only assert events that happen inside the component. Spies are a way for us to hook into the internal mechanisms of our components to assert what is happening.

Get hands-on with 1300+ tech skills courses.