jestjs/jest

Unable to find tests when path includes parentheses

benfogel opened this issue ยท 26 comments

Bug

When running npm test on a project which contains parentheses in the path, no tests are found.

Example repo here: https://github.com/benfogel/jest-18-parenthesis-bug

What is the expected behavior?
A test should be found and run.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Jest 18
Windows 7
NPM 3.10.8

Based on this test it's a known limitation.

@cpojer do we have plans on fixing Windows issues like this?

yeah this should be made to work on windows. The integration tests are disabled on windows mostly because nobody had time to go through and fix/enable the tests. cc @Daniel15 do you have any time to help?

Related: #3121

Looks like this isn't the first time it's broken: #1081
I just had this issue trying to set up a Jenkins CI server because the default workspace on Windows is "C:\Program Files (x86)\Jenkins\workspace<project name>"

I found that you can work around this restriction if you are on a Windows system that supports short names for paths by using the short name, which shouldn't contain the parenthesis, for the rootDir config property.

I think this is fine in the current alpha, jest@test.

Just tested with jest@test (v21.0.0-alpha.2) . Still has issues with paths that include parentheses on windows. Jest finds and runs my tests from C:\Program Files\tmp\project, but not from C:\Program Files\tmp (x86)\project.

Windows Version: 10.0.15063 Build 15063
Node: 8.4.0
NPM: 5.3.0
Jest: v21.0.0-alpha.2

That sucks. It would be great if you could troubleshoot it and send a PR and test to fix it as I don't have access to any Windows machines.

I'd be happy to, but I'm not sure if I'll have the time in the near future. I spent an hour or so digging through to see if it was a quick fix but I couldn't track down the issue, and I can't spend any more time than that from work. Sorry!

For me npx jest works - however npm run-script unit (which executes jest test/unit/specs --coverage under the hood) doesn't work.

Hi Guys,

For me, Even with no special characters in the test path I still can't get tests to run.
image

if I use jest with path to the spec they will execute but otherwise not. Any help greatly appreciated.

why do you run jest/bin/jest? seems like jest thinks /bin/jest is the pattern...

@sean-killeen That seems like a separate issue, you may want to create a new issue with the full template filled out for better help.

@SimenB @ansballard Thanks for your help. So I got this resolved by using the global installation of Jest rather than referencing it through my node_modules.

@sean-killeen
Personally, I completely eschew global installation of any modules needed for node projects and would advise you to do the same unless you have control over all machines running your project. Even in grunt projects, I do not use grunt-cli. I've repeatedly seen problems in systems relying on global packages due to divergent versions. I use jest locally through npm, no issues there. I'm running Windows 10. Maybe try that as well? Hope this helps ๐Ÿ˜

Same issue when trying to run the https://github.com/nrwl/nx e2e on Windows 7 (jest version 20.0.4)
see https://github.com/nrwl/nx/blob/4184bb2d133a7d9fe3eda0ddd3fda40ae5082b1c/scripts/e2e.sh
directly using ./node_modules/.bin/jest, a global install, or npx, didn't resolved anything.

No tests found
In D:\git\gh\nx
  295 files checked.
  testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 45 matches
  testPathIgnorePatterns: \\node_modules\\ - 295 matches
Pattern: "build/e2e/schematics/command-line.test." - 0 matches

FYI : I use git-bash

Any idea when this gets into production? Using v22.4.3 and getting issues when trying to us CI with Jenkins.
Path: C:\Program Files (x86)\Jenkins\workspace\Outages\app\server

We're gearing up for Jest 23, so some ways off.

You can install jest@beta to at least test that it works

Still it doesn't work with WIN : 10 jest : 23.0.0-alpha.6r

:(

@bharathvaj1995 mind setting up a reproduction?

My workaround for a personal project #7842

Also unable to find tests on Mac when asterisk (*) in path:

"No tests found, exiting with code 1"

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.