cypress
cypress copied to clipboard
Cy.Intercept is not working if url has json query parameters
Current behavior
Tried to intercept the below url (one of the query param is json), it is not intercepting.
Example: https://stage.1000.com/main/delivery?action=Entry&file=134561&mode=truck&jsonDel={%22date%22:%2208/13/2022%22,%22period%22:%22M%22}
Note: jsonDel param value is json object
I tried the below commands for intercepting the above url. But it not intercepting
cy.intercept('*main/delivery?action=Entry*).as('entry') cy.intercept('**main/delivery?action=Entry**).as('entry')
Desired behavior
Cypress should handle the url if query param is json object.
Test code to reproduce
This is private code, so i could not share this project
Cypress Version
10.4
Node version
v16.13.1
Operating System
macOS 11.6.4
Debug Logs
No response
Other
No response
@rachelruderman @nagash77
Also cy.intercept is not working if url contains Date query parameter is in the following format mm/dd/yy
https://test.1000.abc.com/sales/entryfile?action=process&entryFile=100200&installSaleIdc=N&date=09/25/22&mode=s
I tried with the below, it is not working cy.intercept('**sales/entryfile?action=process**).as('entryFile') cy.intercept('**sales/entryfile?action=process*).as('entryFile')
@varshanharshank typo ? The intercept example you provide does not have a final ' to end the string ...
Hi @varshanharshank , thank you for reporting!! I made a reproducible example here and confirmed the behavior you're seeing. We'll route this one over to the team 🙏
Hi @varshanharshank , thank you for reporting!! I made a reproducible example here and confirmed the behavior you're seeing. We'll route this one over to the team 🙏
@rachelruderman Could you able to reproduce this issue . if query parameter value as mm\dd\yy instead of mm-dd-yy. cy.intercept is not working if the url as below
https://test.1000.abc.com/sales/entryfile?action=process&entryFile=100200&installSaleIdc=N&date=09/25/22&mode=s
I tried with the below, it is not working cy.intercept('**sales/entryfile?action=process**).as('entryFile') cy.intercept('**sales/entryfile?action=process*).as('entryFile')
@rachelruderman Any update about this issue? when this bug will be fixed?
Hi @varshanharshank, thank you for following up. This has been routed over to the team and is currently in their backlog. Unfortunately I can't give a timeline on when it will be picked up -- we have a lot on our plate and there's many things we'd like to do but they all have competing priorities.
If others who are experiencing this issue upvote it, that will help prioritize it more highly.
As an open-source product, we also welcome contributions and would be happy to review any PRs fixing the issue you encountered 🙌
I'm running into something similar. I'm using this intercept:
cy.intercept('api/search-by-position?pos=**', mockData)
It intercepts this request:
api/search-by-position?pos=%7B%22x%22%3A-10.1575%2C%22y%22%3A-0.5456542%7D&maxDist
But fails to intercept this request:
api/search-by-position?pos={"x":-10.1575,"y":-0.5456542}&maxDist
Could this have to do with the use of JSON as a query param?
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.
This issue has been closed due to inactivity.