-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Make querystrings consistent #20302
Conversation
Thanks for taking the time to open a PR!
|
@sainthkh This looks like this change would be a breaking change, correct? |
@jennifer-shehane It's somewhere between. If we define If we define |
@sainthkh Thanks for the clarification. I believe we'll need to sync on how we plan to proceed. Right now we don't have as much time to dedicate to review of this, so please be patient. |
I like the change - the consistency is valuable, but do think it's breaking. Currently proposing to the team that we merge this when we're ready to release another breaking change (but not cause 11.x immediately for this purpose alone). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a merge conflict, but otherwise looks good to me, with tests covering the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ❤️ consistency, thank you for the contribution and very detailed description!
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
cy.request()
,cy.visit()
andcy.intercept()
query strings are inconsistent #19407User facing changelog
cy.visit()
andcy.request
generate the same querystring.Additional details
qs
argument,cy.visit()
andcy.request()
created different querystrings.mergeUrlWithParams
function used incy.visit()
to generate querystring incy.request
. I decided it this way because cy.visit() behavior is consistent with the defaultURLSearchParams
class.How has the user experience changed?
Before:
After:
Why this PR doesn't close the issue?
AFAIK, there are 3 APIs in Cypress that use query string object. Before this PR, they all used the different libraries.
cy.visit
:url-parse
, which usesquerystringify
cy.request
:qs
cy.intercept
: defaultURLSearchParams
class.This is quite a mess because the standard library(
URL
andURLSearchParams
classes) came out really late with Chrome 49 in 2016 while the libraries above are created in 2011(qs
, nodejs defaultquerystring
), 2014(querystringify
,url-parse
).And Cypress was created before 2016, it's natural that those libraries are used.
This PR deprecates
qs
incy.request
, and usesurl-parse
for bothcy.visit
andcy.request
. It meanscy.intercept
still usesURLSearchParams
.I chose this way because there are 2 ways to merge parameters in
URLSearchParams
:append
andset
. I couldn't be sure mimicking current behavior is right.Currently, when you provide parameters in both
url
andqs
and names are conflicted, values inqs
are used like below.(It's happening because we simply merge objects like below:)
cypress/packages/driver/src/cypress/location.ts
Lines 160 to 165 in 0143e13
But when we use
URLSearchParams
, we can preserve both of them withappend
method like below:I think it is the better behavior. So, I decided to stop this PR here and seek your opinions about this.
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?