Skip to content

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

Closed

Description

@rimunroe

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): react-scripts@1.0.16

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.

Activity

  1. gaearon commented on Nov 6, 2017

    @gaearon
    Contributor

    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.

  2. rimunroe commented on Nov 6, 2017

    @rimunroe
    Author

    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.

  3. added this to the milestone on Dec 8, 2017
  4. Timer commented on Dec 8, 2017

    @Timer
    Contributor

    Tagging as up for contributions.

  5. gaearon commented on Jan 8, 2018

    @gaearon
    Contributor

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

  6. locked and limited conversation to collaborators on Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions