cy.wait() does not resolve aliases in Cypress 6.0.x
See original GitHub issueCurrent behavior
After upgrading from the latest version of v5 to v6.0.0, we are seeing issues with cy.wait()
not resolving aliases set with cy.intercept()
. When our app makes the request, Cypress shows that the request matched and the count # under routes shows 1. See screenshot. Additionally when the route is hit, hovering over where the request occurred in the runner shows “<route> ResponseReceived aliased as: pinReport”. The subsequent cy.wait()
command however times out after the default timeout saying that request never occurred.
Temporarily switching back to cy.route()
also results in the same issue.
Important to mention also is that this happens about 50% of the time. Sometimes cy.wait()
knows the request happened and the test passes, other times it times out like in the screenshot below.
Desired behavior
cy.wait()
should resolve the alias when matched by cy.intercept()
Test code to reproduce
it('should pin a report', () => {
cy.intercept({
method: 'POST',
path: '/api/report_for_report_indices/*/star',
}).as('pinReport');
cy.getByTestId('button__pin')
.first()
.click({
force: true
});
cy.wait('@pinReport')
.its('response.statusCode')
.should('eq', 204);
});
Versions
Cypress version v6.0.0 and v6.0.1 Worked with Cypress v5.x Browser: Chrome Version 87.0.4280.67 (Official Build) (x86_64) Operating System: macOS, also ran reproducible in GitHub Actions on a ubuntu-18 container
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:21 (7 by maintainers)
Top GitHub Comments
url
now matches the full url, including the base path (hostname). For your first example, you would usepath
instead which excludes the hostname.Well, something with the url is definetaly changed. (cypress 6.0.1 and cypress 6.1.0)
wait for this alias fails, but worked before (with route)
this works:
But the cypress log shows:
Something is prepended to the url, but it is not visible anywhere. I hope this helps someone.