Skip to content
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

cy.visit() and URL encoding #5034

Closed
Doogiemuc opened this issue Aug 23, 2019 · 4 comments · Fixed by #5040
Closed

cy.visit() and URL encoding #5034

Doogiemuc opened this issue Aug 23, 2019 · 4 comments · Fixed by #5040
Assignees
Labels
type: feature New feature that does not currently exist

Comments

@Doogiemuc
Copy link

Doogiemuc commented Aug 23, 2019

Current behavior:

Cypress does not support URL encoding at all. Ok I know this is the responsible of the HTTP 'client', but it would be nice if the cy.visit() function would support URL encoding in a similar way as any other JS REST client does.

Just for clarification: I am talking about URL parameters. Not HTTP headers. And also not POST body.

Desired behavior:

cy.visit() should have a parameter params of type object. The passed values in this object will be URL encoded and then all attributes are sent as parameters in the request URL.

Steps to reproduce: (app code and test code)

This code should work:

    cy.visit('/search, { params: { searchQuery: "some example string with spaces" }}
    // => GET /search?searchQuery=some%20example%20string%20with%20spaces
   
    cy.visit({
      method: 'GET',
      url: '/fetch
      params: {
        foo: 'bar'
      }
    }
    // =>GET /fetch?foo=bar

Versions

all cypress versions. Yes ok, this is a feature request.

@Doogiemuc
Copy link
Author

Doogiemuc commented Aug 23, 2019

Of course there is a workaround: Encode your URLs yourself with encodeURI() like we do since 1995 :-) Just kidding. The "params" parameter is pretty common. And there are also many use cases, where passing a (dynamically generated) object as params is necessary. For example one might want to pass some test fixture data here.

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Aug 26, 2019
@jennifer-shehane jennifer-shehane added the type: feature New feature that does not currently exist label Aug 26, 2019
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Aug 26, 2019
@flotwig
Copy link
Contributor

flotwig commented Aug 26, 2019

We can pass through the qs parameter which is already supported by the request library. Opened a PR: #5040

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs review The PR code is done & tested, needs review stage: work in progress labels Aug 26, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Sep 17, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 17, 2019

The code for this is done in cypress-io/cypress#5040, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2019

Released in 3.5.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature New feature that does not currently exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants