Home
Basics
Introduction Environment Setup Cypress Components First Test Running Tests Reports Element Identification GUI interaction Cypress Hooks Cypress Fixtures Integration with CI serversAdvanced
Page Object Model Custom Commands Intercepting Requests Backend Testing Interview Questions and AnswersIntercepting the ajax requests in Cypress
cy.intercept('GET', '**/get-product/*').as('getProduct')
cy.get('.buy-btn').click()
cy.wait('@getProduct').its('response.statusCode').should('eq', 200)
Mock Response
cy.intercept('GET', '**/get-product/*').as('getProduct')
cy.intercept('GET', '**/get-product/*', { fixture: 'product.json' }).as('getProduct')
cy.get('.buy-btn').click()
cy.wait('@getProduct').its('response.body')
.should('have.property', 'name')
.and('include', 'fake product name')
Web development and Automation testing
solutions delivered!!