Complete the code to intercept a GET API call using Cypress.
cy.intercept('GET', [1]).as('getData')
The intercept method requires the HTTP method and the URL pattern. Here, 'GET' is fixed and the URL '/api/data' is the correct endpoint to intercept.
Complete the code to wait for the intercepted API call to finish.
cy.wait([1])When you alias an intercept with .as('getData'), you wait for it using cy.wait('@getData'). The '@' symbol is required.
Fix the error in the assertion to check the API response status code.
cy.wait('@getData').its('response.statusCode').should([1], 200)
The correct assertion method in Cypress is 'equal' to compare values.
Fill both blanks to assert the API response body contains the expected user name.
cy.wait('@getData').its('response.body').should([1], [2])
To check if the response body has a property 'name', use 'have.property' and 'name'.
Fill all three blanks to intercept a POST request, wait for it, and assert the response status is 201.
cy.intercept([1], [2]).as('postUser') cy.wait([3]).its('response.statusCode').should('equal', 201)
Intercept the POST method to '/api/users', alias it as 'postUser', then wait for '@postUser' and check status 201.