cy.intercept should provide req.query since the url has the query object
See original GitHub issueCurrent behavior
req.url
looks like http://hostname:port/?someKey=someValue
but req.query
is undefined
.
Desired behavior
req.url
looks like http://hostname:port/?someKey=someValue
and req.query
is { someKey: 'someValue' }
.
Test code to reproduce
cy.intercept({ hostname }, (req) => {
console.log(req.query) // undefined
console.log(req.url) // http://hostname:port/?someKey=someValue
})
Versions
Cypress: 7.2.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
intercept - Cypress Documentation
The routeHandler function is called whenever a request is matched, with the first argument being the request object. From inside the callback, you...
Read more >cypress - cy.intercept() for post endpoints with query parameters
I tried the same thing for a post endpoint that requires a query params in the URL but it didn't work. In the...
Read more >A Practical Guide to Intercepting Network Requests in Cypress
Our .intercept() command is now matching any request that contains the url /api/boards . You can see this in a screenshot below.
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
The command cy.intercept can match requests using a substring, a minimatch, or a regular expression. By default, it intercepts requests matching ...
Read more >Cypress - intercept Spy and stub network requests responses.
cy.intercept() is the successor to cy.route() as of Cypress 6.0.0. ... you have access to the entire request-response where you can modify the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The code for this is done in cypress-io/cypress#16916, but has yet to be released. We’ll update this issue and reference the changelog when it’s released.
Yeah, I agree that it’s weird to not have
query
. The only problem with this proposal is thatreq.url
contains the querystring and can be modified, so it stands to reason thatreq.query
can be modified as well. So, if aquery
property was added, any changes the user makes to it would have to be reconciled with changes toreq.url
somehow.IMO the best way to implement this would be to add
req.query
, but make it just a fancy getter/setter forreq.url
, so the two can never be out of sync. What do you two think?