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

Tests won't run if the project's root path contains parentheses #3404

Closed
rimunroe opened this issue Nov 3, 2017 · 4 comments
Closed

Tests won't run if the project's root path contains parentheses #3404

rimunroe opened this issue Nov 3, 2017 · 4 comments

Comments

@rimunroe
Copy link

rimunroe commented Nov 3, 2017

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Yes

Which terms did you search for in User Guide?

  • path
  • parens
  • parentheses
  • testMatch

Environment

  1. node -v: v6.10.3
  2. npm -v: v3.10.10
  3. yarn --version (if you use Yarn): N/A
  4. npm ls react-scripts (if you haven’t ejected): [email protected]

Then, specify:

  1. Operating system: macOS 10.12.6
  2. Browser and version (if relevant): N/A

Steps to Reproduce

  1. Create a directory with parentheses in the name: mkdir with-\(parens\)
  2. Navigate to that directory: cd with-\(parens\)
  3. Create a new app using create-react-app: create-react-app parens
  4. Go into the newly created my-app directory: cd parens
  5. Install dependencies: npm install
  6. Run tests: npm test
  7. You should see a prompt that says "No tests found related to files changed since last commit."
  8. Press "a" at the prompt to run all the tests.

Expected Behavior

The tests in src/app.test.js should be run.

Actual Behavior

A message about no tests being found will be shown.

image

Reproducible Demo

https://github.com/rimunroe/create-react-app-parens-in-test-path

It looks like the parentheses in the path that make up the <rootDir> later passed to Jest's testMatch option by create-react-app's config are being interpreted by Jest as grouping characters. I've filed this as an issue with Jest jestjs/jest#4838 as well.

@gaearon
Copy link
Contributor

gaearon commented Nov 6, 2017

Maybe we need to escape them first?

Regardless, there are bigger issues with parentheses, such as broken watcher behavior in webpack.

We should probably just fail early in this case and ask to move the project folder.

@rimunroe
Copy link
Author

rimunroe commented Nov 6, 2017

If escaping is an option and can be done reliably, then that would be great. However, I'm not sure it is an option. I don't know how things work pre-eject, but post-eject, the jest config section of package.json will include the <rootDir> template variable in the values of testMatch. At that point, I don't believe that there would be anything that could be done to tests to run.

@Timer
Copy link
Contributor

Timer commented Dec 8, 2017

Tagging as up for contributions.

@gaearon
Copy link
Contributor

gaearon commented Jan 8, 2018

This got fixed in jestjs/jest#5224 so it's not actionable here anymore. Thanks!

@gaearon gaearon closed this as completed Jan 8, 2018
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants