-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Can't run a single test file specified by name via the CLI #3793
Comments
Does it work when you pass only |
@rogeliog: no. That was the first thing I've tried. |
Can you rename file to my.test.js? Looks like testMatch doesn't match your filename, but I may be wrong on that, looking through my phone |
@thymikee: If I rename the file to |
@dandv I think it would be nice to make it work, but It's not a priority. Feel free to work on this :) |
Maybe you can change the |
The docs claim it works, and every single command-line build tool I've ever used that takes a file parameter, actually uses that particular file. Jest doesn't, which is super counter-intuitive.
That will only hide the problem above.
I understand. Not sure I really have the time to dive into yet another new project right now though. |
I assume the problem is that Jest is always using regex to match file names. When you are on Windows, and the path separator is
The macro |
Got a similar problem running in windows.
Running similar command on Mac the test is found.
Made a repo to reproduce it. https://github.com/lindgr3n/jest-single-test Note: that running following works on windows so you can work around it in this case.
|
I'll take this up. |
This appears to be working in v21.2.1 possibly in just v21.x.x... |
@dandv can you confirm that in your case? |
@mruzekw @thymikee I think there is still an issue with this, I need to escape the backslash to make it work. (Windows 10, plain Command Prompt) Not escaped doesn't find the test:
This one works:
|
I've just run into the same problem which affects teams developing across platforms. Someone's got their
If we drop |
Has anyone come up with a temporary solution to this issue? As couple of new guys in our project with windows laptops are having issues. And it gets quite fast annoying to escape backslash every time you want to run a single test file. |
Alright @Hetachi, the thread bump worked. I'll submit a PR after figuring out how to test this. |
* Add tests for current testPathPattern behavior * Escape Windows path separator in testPathPattern CLI arg This fixes #3793. * Add PR to CHANGELOG.md * Insert ';'
@cpojer, could you please reopen this issue? #5054 didn't fix the original issue that #3882 will. We still need to sort out how The conversation in #5216 brought up the edge case when the Windows
I'd like to make 3 suggestions:
|
Thanks for your hard work. I am still experiencing this issue on Win 10 using version 22.1.2. If I use forward slashes pattern like so:
it says
This behavior is observable on both cmd and PS If I use escaped Windows style (\) it works, but this is not good enough for me (I'm trying to configure VSCode to run tests from current file and I can't escape backward slashes in fileName variable) |
Same issue with 22.4.2? |
this version works as expected! Thanks. |
This still doesn't seem fully fixed in 23.4.1 - files with other extensions (notably .mjs) aren't found. $ mkdir jestbug && cd jestbug
$ npm init -y
$ npm install --save-dev jest
$ echo "foo" > test.mjs
$ node_modules/.bin/jest test.mjs
No tests found
In /home/dandv/jestbug
2 files checked.
testMatch: **/__tests__/**/*.js?(x),**/?(*.)+(spec|test).js?(x) - 0 matches
testPathIgnorePatterns: /node_modules/ - 2 matches
Pattern: test.mjs - 0 matches
$ cat test.mjs
foo I think that regardless of the value of Passing a matching wildcard to $ node_modules/.bin/jest --testMatch te*
No tests found
In /home/dandv/jestbug
1 file checked.
testMatch: te* - 0 matches
testPathIgnorePatterns: /node_modules/ - 2 matches
Pattern: - 0 matches |
In case the later comers would also wonder why. I found out the reason could be because And of course, one can change the default using CLI option or in config file. |
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. |
The docs claim that I should be able to run
jest path/to/my-test.js
. When I do that, I get this error:I'm using jest v20.0.4 and zsh. Running
./node_modules/.bin/jest ./my-test.js
underbash
produces the sameNo tests found
result.The text was updated successfully, but these errors were encountered: