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

Run specs with name containing '+' #8015

Merged
merged 6 commits into from
Jul 23, 2020

Conversation

laistomazz
Copy link
Contributor

User facing changelog

Now you can run specs with name containing '+'

Additional details

The issue is using req.query.p when handling the spec. This is part of an example of the req object:

originalUrl: '/__cypress/tests?p=cypress/integration/issue+filename.spec.js',
  _parsedUrl: Url {
    protocol: null,
    slashes: null,
    auth: null,
    host: null,
    port: null,
    hostname: null,
    hash: null,
    search: '?p=cypress/integration/issue+filename.spec.js',
    query: 'p=cypress/integration/issue+filename.spec.js',
    pathname: '/__cypress/tests',
    path: '/__cypress/tests?p=cypress/integration/issue+filename.spec.js',
    href: '/__cypress/tests?p=cypress/integration/issue+filename.spec.js',
    _raw: '/__cypress/tests?p=cypress/integration/issue+filename.spec.js'
  },
  params: {},
  query: { p: 'cypress/integration/issue filename.spec.js' },

Why this happens

Express's req.query parser is based on Node's native query parser, querystring. It will replace + with a space by default.
Screenshot 2020-07-17 at 16 09 09

Proposed solution

Quick fix: To not use the query parameter.
ezgif-3-f3f1ead8f3df

Proposed followup solution

Have a custom query string parsing function.

How has the user experience changed?

Now they won't see an error anymore if the spec file contains "+".

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 17, 2020

Thanks for taking the time to open a PR!

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laistomazz Thanks! Can you add a test around this new behavior?

There is a Contributing Guide that covers how to contribute and get Cypress running locally in generally here: https://github.com/cypress-io/cypress/blob/develop/.github/CONTRIBUTING.md

Here's an example of another issue's test code below. I believe you should just be able to add a simple spec file called 5909+spec.js, since the presence of the + would make the test fail.

To run the tests:

  • within cypress root, run yarn
  • run yarn workspace @packages/driver cypress:open
  • click on the test you're writing to run it within Cypress

Instructions for running the driver tests can always be found here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/README.md

@laistomazz
Copy link
Contributor Author

The failing tests show that my solution doesn't work for all cases. I will look further into it.

@laistomazz
Copy link
Contributor Author

laistomazz commented Jul 21, 2020

It was an easier fix than I thought 😅

Any suggestion on how to fix the failing test? /packages/server/test/e2e/5_screenshots_spec.js

Locally it fails on /Users/username/cypress/packages/server/test/e2e/5_screenshots_spec.js:102:38

1) e2e screenshots passes [chrome]:
     AssertionError: expected 192864 not to be close to 193512 +/- 5000

@jennifer-shehane
Copy link
Member

@laistomazz just some flake, is fine now.

@jennifer-shehane jennifer-shehane dismissed their stale review July 22, 2020 06:42

Dismissing previous request for tests since tests exist now

@jennifer-shehane jennifer-shehane merged commit a1c562f into cypress-io:develop Jul 23, 2020
@laistomazz laistomazz deleted the issue-5909 branch July 23, 2020 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

file name contains character ”+“ not run
3 participants