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
265 stars 124 forks source link

Test path results in no tests being executed #181

Closed sim099 closed 3 years ago

sim099 commented 3 years ago

I'm running The following VSCode under Windows 10.0.19042 Build 19042:

Version: 1.56.2 (system setup)
Commit: 054a9295330880ed74ceaedda236253b4f39a335
Date: 2021-05-12T17:13:13.157Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.19042

When I click on "Run", a command line similar to this is executed: node "c:/Users/path/to/git/repo/node_modules/jest/bin/jest.js" "c://Users//path//to//git//repo//api//__tests__//unit//module/.test/.js" -c "c:/Users/path/to/git/repo/api/jest.config.js" -t "update-elements-stats tests"

The command runs successfully but doesn't find any tests to run. It looks like the path to the actual test file was originally in windows format and escaped with \, but the \ have been replaced with /. This results in the path used including double // and the filename it's looking for being module/.test/.js, meaning that the file isn't found.

LewisHogan commented 3 years ago

I also encountered this issue on 0.4.35, downgrading the extension to version 0.4.34 appears to work for me.

sim099 commented 3 years ago

I also encountered this issue on 0.4.35, downgrading the extension to version 0.4.34 appears to work for me.

That's worked for me too.

Thanks 👍

mvanalphen commented 3 years ago

Can confirm the same issue on Windows.

MikeRippon commented 3 years ago

Same issue on windows. Looks like it's trying to escape special characters using a forward slash, presumably due to #162

c://some-dirs//mytest/.test/.js

firsttris commented 3 years ago

which shell are you using on windows? with powershell or bash it should work, only with commandline you should face this issue. is this correct?

LewisHogan commented 3 years ago

I'm using Powershell 7.1.3, though I seem to face the same issue in cmd as well

sim099 commented 3 years ago

which shell are you using on windows? with powershell or bash it should work, only with commandline you should face this issue. is this correct?

PowerShell

I wasn't sure how to see which version, but a quick Google revealed the following

PS C:\repo_path> Get-Host | Select-Object Version  

Version      
-------      
5.1.19041.906
gjorgjivladimirov-allocate commented 3 years ago

I can confirm the same issue. Downgrading to 0.4.34 works fine. Issue is the command when it's executing the test: The test file name is: test-foo.spec.ts It's adding extra '/' everywhere even on the name... node "c:/Workspaces/project-test/node_modules/jest/bin/jest.js" "c://Workspaces//project-test//src//__tests__//moduleTest//test-foo/.spec/.ts" -t "Foo_Bar\.yml test data"

Cellule commented 3 years ago

Also good to note that clicking "debug" does not have the same problem. Meaning the special character "fix" isn't applied when debugging. The main problem is that the regex escape is executed before the normalizePath in buildJestArgs which converts \ to / effectively breaking the regex. Weirdly though I tried to manually put back backspaces in the command passed and it still didn't work. I think that "escapeRegex" fix was incorrect, insufficiently tested and requires a bit more thinking and should be reverted for now

https://github.com/firsttris/vscode-jest-runner/blob/ac4ade9dd763e8c2e647171ffe099f6476698d0f/src/jestRunner.ts#L162-L166

RyanElfman commented 3 years ago

Downgrade worked for me as well :)

firsttris commented 3 years ago

i might have found the issue, and tested on my windows machine.

v 0.4.38 should fix this issue, if not please re-open.

thx for reporting

sim099 commented 3 years ago

i might have found the issue, and tested on my windows machine.

v 0.4.38 should fix this issue, if not please re-open.

thx for reporting

It was v0.4.39 by the time I installed the update a few minutes ago, but it does indeed work.

Thanks for fixing!