cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Cy.Intercept is not working if url has json query parameters

Open varshanharshank opened this issue 2 years ago • 7 comments

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

varshanharshank avatar Aug 15 '22 14:08 varshanharshank

@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 avatar Aug 17 '22 04:08 varshanharshank

@varshanharshank typo ? The intercept example you provide does not have a final ' to end the string ...

AurelienKun avatar Aug 17 '22 09:08 AurelienKun

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 avatar Aug 18 '22 17:08 rachelruderman

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')

varshanharshank avatar Aug 19 '22 15:08 varshanharshank

@rachelruderman Any update about this issue? when this bug will be fixed?

varshanharshank avatar Sep 08 '22 03:09 varshanharshank

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 🙌

rachelruderman avatar Sep 13 '22 23:09 rachelruderman

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?

mracette avatar Sep 19 '22 15:09 mracette

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.

github-actions[bot] avatar May 12 '23 17:05 github-actions[bot]

This issue has been closed due to inactivity.

cypress-app-bot avatar May 31 '23 20:05 cypress-app-bot