Implementing network requests
Network requests involve the handling of AJAX and XHR requests to the backend services. Cypress handles this with its in-built cy.request()
and cy.intercept()
commands. In this section, we will take a hands-on approach and dive deep into how we implement network requests in Cypress using examples and exercises. We have previously interacted with network requests in Chapter 9, Advanced Uses of Cypress Test Runner, of this book and this chapter will help you build on the theoretical knowledge and concepts that you are already familiar with.
cy.request()
The Cypress cy.request()
command is responsible for making HTTP requests to API endpoints. This command can be used to execute API requests and receive responses without the need to create or import an external library to make and handle our API requests and responses. Our Cypress finance application uses a backend API that is based on a JSON database. To learn how the cy.request()
command works, we...