vscode-jest-runner
vscode-jest-runner copied to clipboard
`Run` button: "No tests found, exiting with code 1"
Based on what I see in your demo output (below image), you are sending a command with an absolute path like below:
node 'node_modules/.bin/jest' '/home/me/my_project/test/something.test.ts'

But though I see this in my vs code terminal such a valid path is being used, it doesn't work for me (nor does just running the command itself), and I don't understand how it could based on jest
documentation since this argument is meant to be a regex.
If I do a relative path (below), I see jest
work for me, but Run
button doesn't (and probably can't?) send a relative path:
node 'node_modules/.bin/jest' 'test/something.test.ts'
Does this extension (and those like it, that send absolute paths) only work for certain older versions of jest
? Might there be some other problem with my setup that could cause this issue?
I'm on:
node 'node_modules/.bin/jest' --version
29.1.2
What OS and which terminal are you using?
AmazonLinux2 and zshell.
% uname -a
Linux ... 5.4.209-129.367.amzn2int.x86_64 #1 SMP Wed Aug 31 17:08:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
% zsh --version
zsh 5.8.1 (x86_64-koji-linux-gnu)
(I see no difference switching to bash
.)
- its strange that its not working for you: but if you change the path to relative and then its working its most likely the reason that somhow the jest regex does not match the test.
- alot people are using the extension and im not aware of such an issue.
- i just tested with arch linux and bash as well as fish and its working fine.
- i think your right a absolut path should not be required, i also dont remember why we use absolute path, relative would be better.
- i could not find out how to get relative path with vcode api. heres the line where we get the absolute path:
- https://github.com/firsttris/vscode-jest-runner/blob/master/src/jestRunner.ts#L61 (run Jest)
- https://github.com/firsttris/vscode-jest-runner/blob/master/src/jestRunner.ts#L81 (debug Jest)
Hmm ok. Can you confirm what version of jest
you're testing against?
I've ran into the same issue and it seems to be caused by symlinks. My code is in /dev/project/
where /dev/
is also symlinked to ~/dev/
. If I open VS Code from ~/dev/project/
, the plugin generated an absolute path based on ~/dev/project/
whereas Jest picks up the absolute path from /dev/project/
and so the regex doesn't match. Opening VS Code from /dev/project/
solves the issue.
Yeah, I also have a similiar problem on Windows, using the subst
command to "symlink" a directory to a drive letter. E.g. I have the directory C:\Data
linked do the drive D:\
. Executing a test (with plain jest
) using jest D:/file/to/test
, doesn't work, whereas jest C:/Data/file/to/test
does. So it seems it's not directly a problem with the extension, but more with jest (or node).
So my workaround is to import the project from the C:/Data
directory into VSCode instead of the one from D:/
. This works with using the extension. I don't know if it's possible to resolve the symlinks in a VSCode extension, so it would pass this file name to the jest command instead. Using a relative path would be nice, too.
For context, I'm running jest 27.5.1 and node 16.16.0