-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
cy.wait for alias registered to non-first matching cy.intercept does not have response property (body & status) #14205
Comments
Having the same issue on some requests with intercept(). But works as expected with route() |
Same as this , already filed since the release 5.6.0 |
I can reproduce this with the given example. I believe this is because the alias is registered to the second intercept. We don't support overriding intercepts that match exactly, but are working on support: #9302 I'm not completely sure this will be resolved by that solution though, so I'm leaving this open. I actually think this is this issue, but Kevin said his issue was resolved. #9262 So, I'll leave this issue open as the reproducible example. Reproducible exampleit('route should work', () => {
cy.server()
cy.route('GET', '**/comments/*')
cy.route('GET', '**/comments/*').as('getComment')
cy.visit('https://example.cypress.io/commands/waiting')
cy.get('.network-btn').click()
// ✅ passes 'status' does exist
cy.wait('@getComment').its('status').should('be.oneOf', [200, 304])
})
it('intercept should work', () => {
cy.intercept('GET', '**/comments/*')
cy.intercept('GET', '**/comments/*').as('getComment')
cy.visit('https://example.cypress.io/commands/waiting')
cy.get('.network-btn').click()
// ❗️ fails 'response' does not exist
cy.wait('@getComment').its('response.statusCode').should('be.oneOf', [200, 304])
}) |
@jennifer-shehane Any update on this bug fix? When shall we expect fix for this bug. Thanks. |
As a work around, To get response from an intercept(). Intercept an API, Take the request from the intercepted method. Then use cy.request() for that intercepted URL and body (if present). And then find the response from cy.request(). It's not best practice. But can help as a work around in case we need response from the intercepted API. |
@VinitMaheswari could you please provide an example with code? |
HI @core01 Please find the below code and Let me know if you need any help. The same piece of code is working for me. cy.intercept('POST', '/API Need to be intercpeted**').as('intercept'); |
The code for this is done in cypress-io/cypress#15528, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Hi guys, thank you so much for new intercept method, it is a great job!
But I have a problem, I need to have an opportunity to modify body for all requests to
API
to passisTestData
flag which will indicate that this data was created by cypress and it can be deleted. To do this I createdbeforeEach
for all test cases and addcy.intercept
for allPOST
requests, but It breaks the ability to receive a response body or status incy.wait
.Current behavior
response property doesn't exist

Desired behavior
response property should always exist
Test code to reproduce
I created a repo with a small test case which show my problem https://github.com/core01/cypress-intercept/blob/main/cypress/integration/spec.js
And below you can see a code from a project I'm working on:
support/beforeEach.js:
support/commands.js:
support/index.js:
Versions
Cypress 6.1.0
Chrome/Electron. Mac Big Sur
The same problem was described in this comment, but I think that it deserves a separate issue
Related issue - #8493
The text was updated successfully, but these errors were encountered: