cy.intercept url change not detected during file watching in Cypress open
See original GitHub issueCurrent behavior
This issue occurred migrating the Cypress RWA from cy.route
to cy.intercept
.
A cy.route
with a minimatch is converted to use cy.intercept
:
Note: Two aliases are defined against the same path (/users)
beforeEach(function () {
cy.intercept("GET", "/users").as("allUsers");
cy.intercept("GET", "/users/search*").as("usersSearch");
})
When run in open mode the test fails:
Migrating from cy.route
to cy.intercept
requires a glob-match (**
) to be added to the beginning of the route.
The glob-match is added without stopping the current run and the file is saved:
beforeEach(function () {
cy.intercept("GET", "/users").as("allUsers");
cy.intercept("GET", "**/users/search*").as("usersSearch");
})
The browser refreshes and fails against a different alias:
Solution Stop the current run and start a fresh run, where the glob-match is honored and the tests pass as expected
A detailed demo of the issue and the solution is in this Loom:
https://www.loom.com/share/33778ef182bd489c80efa2d941e4e9f1
Desired behavior
When a glob-match is added to a cy.intercept
the test runner should reflect that code change during the current run.
Test code to reproduce
See the Loom video and this diff in the RWA against the new-transactions.spec.ts
where it can be reproduced: https://github.com/cypress-io/cypress-realworld-app/commit/504652c4561db611d6c54a8a40cdd3fea4db6bb1
Versions
6.0.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top GitHub Comments
It doesn’t work
Was just looking into this myself and it appears that
cy.intercept
does still support mini-match, but you have to pass an object with apathname
attribute including your glob string.For example:
cy.intercept("GET", "/users/search*").as("usersSearch")
becomes