jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.16k stars 6.45k forks source link

Unable to find tests when path includes parentheses #2381

Closed benfogel closed 2 years ago

benfogel commented 7 years ago

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

thymikee commented 7 years ago

Based on this [test](https://github.com/facebook/jest/blob/ec782b567bf343d9d278cd79265a1af2bfc3e83c/integration_tests/__tests__/regex-\(char-in-path-test.js) it's a known limitation.

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

cpojer commented 7 years ago

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?

PeteDuncanson commented 7 years ago

Related: #3121

rally25rs commented 7 years ago

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\"

siirila commented 7 years ago

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.

cpojer commented 7 years ago

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

ansballard commented 7 years ago

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
cpojer commented 7 years ago

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.

ansballard commented 7 years ago

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!

robertmain commented 6 years ago

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

sean-killeen commented 6 years ago

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.

SimenB commented 6 years ago

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

ansballard commented 6 years ago

@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.

sean-killeen commented 6 years ago

@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.

c-vetter commented 6 years ago

@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 😁

nweldev commented 6 years ago

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

KyleScharnhorst commented 6 years ago

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

SimenB commented 6 years ago

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

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

bharathvaj-ganesan commented 6 years ago

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

SimenB commented 6 years ago

:(

SimenB commented 6 years ago

@bharathvaj1995 mind setting up a reproduction?

iondrimba commented 5 years ago

My workaround for a personal project https://github.com/facebook/jest/issues/7842

MattKohnen commented 5 years ago

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

"No tests found, exiting with code 1"

github-actions[bot] commented 2 years ago

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.

github-actions[bot] commented 2 years ago

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.

github-actions[bot] commented 2 years ago

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.