Open BohdanQatestlab opened 1 year ago
Hi @BohdanQatestlab 👋, thanks for logging this issue. I have replicated your issue in the latest version of Cypress and will forward it to the appropriate team. They will evaluate the priority of the issue and consider their capacity to pick it up. Please note that this does not guarantee that this issue will be resolved. The issue will indicate status changes during evaluation. Thanks!
Digging into this a little bit more, when we are waiting to see if the intercept will add an alias, we retry but this retry returns since it thinks the command has failed with an error. The cy.wait
command then resolves with undefined
causing the destructuring error.
@BohdanQatestlab, I believe your workaround works because you just happen to be waiting long enough for the request to be made and the intercept to be hit which adds the alias and allows the wait to succeed.
Current behavior
Description:
In my test suite, I use the cy.wait('@alias') command inside the afterEach block to ensure that all API requests are completed before each test ends. This works correctly if the test case passes, but when a test fails, cy.wait('@alias') returns undefined in response instantly causing a "Cannot destructure property 'response' of 'undefined'" as it is undefined. error.
Steps to reproduce:
Set up an API intercept and alias it. Use cy.wait('@alias') in the afterEach block. Run a test that fails intentionally. Notice that the cy.wait('@alias') in the afterEach block returns undefined.
Additional Info: I have confirmed that the response is not empty via console logs and checking the network tab in the browser dev tools. Also, the issue seems to be mitigated by adding a manual delay before the cy.wait('@alias') command, which suggests that it could be related to some internal promise handling in Cypress.
Desired behavior
Expected Results: The cy.wait('@getPost') command should return an object with request and response properties, even when a test fails.
Actual Results: When a test fails, cy.wait('@alias') returns undefined which leads to a destructuring error.
Test code to reproduce
Cypress Version
12.9
Node version
18.16
Operating System
Ubuntu 22.04.2 LTS
Debug Logs
Other
No response