-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intercept i is not showing the latest respnose if Intercept same call multiple times #20697
Comments
@varshanharshank Can you provide a reproducible example using https://github.com/cypress-io/cypress-test-tiny since you are unable to share you're repo? I tired to reproduce the issue and was unable to. Here is the test I used: it('test intercept response that is used when called multiple times', () => {
cy.intercept('https://jsonplaceholder.cypress.io/*', {
statusCode: 200,
headers: {
'content-type': 'text/html',
},
body: 'response1'
}).as('request')
cy.visit('https://jsonplaceholder.cypress.io/comments')
cy.wait('@request').then(({ response }) => {
expect('response1').to.eq(response.body)
})
cy.intercept('https://jsonplaceholder.cypress.io/*', {
statusCode: 200,
headers: {
'content-type': 'text/html',
},
body: 'response2'
}).as('request')
cy.visit('https://jsonplaceholder.cypress.io/comments')
cy.wait('@request').then(({ response }) => {
expect('response2').to.eq(response.body)
})
}) |
I ran into the same issue (I'm on 9.7.) I discovered using server().route() rather than intercept() worked around the problem. |
I've been having this issue ever since switching to using cy.intercept instead of cy.route. It's a bit hard to find reproducible example without giving access my project. But issue is usually happen when you stay on the same page and do the same request (for example do search with the same text twice). It usually just match wait for to the first route it already matched and give you response of that first route. |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
This issue has been closed due to inactivity. |
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)
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
The text was updated successfully, but these errors were encountered: