firsttris / vscode-jest-runner

Simple way to run or debug one or more tests from context menu, codelens or command plalette
https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner
MIT License
264 stars 124 forks source link

`Run` button: "No tests found, exiting with code 1" #283

Open mooreniemi opened 1 year ago

mooreniemi commented 1 year ago

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'
Screen Shot 2022-10-28 at 12 03 17 AM

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
firsttris commented 1 year ago

What OS and which terminal are you using?

mooreniemi commented 1 year ago

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

firsttris commented 1 year ago
mooreniemi commented 1 year ago

Hmm ok. Can you confirm what version of jest you're testing against?

gnail commented 1 year ago

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.

Sebaestschjin commented 1 year ago

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