cypress: intercept()'s minimatch glob-matching against routeMatcher url property no longer works
Current behavior
In Cypress 4.12.1, matching a route (cy.route()) with a url property that contains a string with minimatch syntax (*) works.
In Cypress 6.0.0, using cy.intercept() with a routeMatcher.url that also contains minimatch syntax fails to match.
The help at https://docs.cypress.io/api/commands/intercept.html#routeMatcher-RouteMatcher says:
All properties are optional. All properties that are set must match for the route to handle a request. If a string is passed to any property, it will be glob-matched against the request using minimatch.The available routeMatcher properties are listed below:
Desired behavior
Glob-matching should succeed with string properties passed to cy.intercept() in a routeMatcher.
Test code to reproduce
Versions
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 16 (8 by maintainers)
We are planning to update cy.intercept() to match the old behavior like cy.route() matching as Zach showed above.
Thank you for addressing this. I await a new release so I can complete my port to Cypress 6.x.
We have most of the examples in our docs passing the pathname as the main argument for matching in
cy.intercept()which is another reason I think no one expected this to be the new behavior.A lot less examples showing the ‘correct’ way in 6.1.0.
Hey @knotthere, Yes, it definetely should. This is a bug from v6.0. I do not doubt it will be fixed in the next release. My work around is for the mean time.
@knotthere
urlis matched as a substring or via minimatch. Can you share your test code that is not working please?