Skip to content

Intercept i is not showing the latest respnose if Intercept same call multiple times #20697

@varshanharshank

Description

@varshanharshank

Current behavior

During end to end testing, I am intercepting the same api call many places (each place, it will provide different response). When i use cy.wait() command to retrieve the response, it is always showing the old response (it means, it is showing response which intercepted first time)

    cy.intercept('**customerInfo/inventory/review/*').as('reviewInvetory')
    cy.wait('@reviewInvetory').then((res) => {
      cy.log(JSON.stringify(res.response?.body))
    }) //printing reviewInvetory1 response
    //doing some action in the application, then again intercepting the same call
    cy.intercept('**customerInfo/inventory/review/*').as('reviewInvetory')
    cy.wait('@reviewInvetory').then((res) => {
      cy.log(JSON.stringify(res.response?.body))
    }) //printing the first call data instead of printing the latest intercept call

Desired behavior

Expecting to show latest call instead of showing the old call

Test code to reproduce

I can't share my repo to public

Cypress Version

9.4

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleno activity on this issue for a long period

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions