Summary
This chapter's focus was mainly on XHR requests and responses and how they interact with the client and the server. We started by first understanding what XHR requests and responses are and how important they are when we want to send requests from the client and also receive requests from the server. In this chapter, we also looked at how we can "fake" server responses by stubbing XHR responses using the Cypress stub functionality that is built into the cy.intercept()
command. Finally, we explored the Cypress cy.spy()
command, which further gave us an idea of how we can monitor methods in Cypress and get the ability to find out the number of times the methods were executed, how they were executed, their arguments, and even their return values. In the final section, we learned the importance of knowing that with spying, we can only "observe" how the execution takes place, and not necessarily have the ability to change the execution process of the request...