Intercepting 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')

        
Complex problems, Simple Solutions