linux-china / vitest-jetbrains-plugin

Vitest JetBrains plugin
https://plugins.jetbrains.com/plugin/19220-vitest-runner
Apache License 2.0
52 stars 6 forks source link

Using the test runner in PHPStorm does not work (WSL) #24

Open HalfLife7 opened 2 years ago

HalfLife7 commented 2 years ago

Running npm exec -- vitest run -t test tests/Frontend/Views/HelloWorld.spec.ts works fine as shown below. image

But when I try to run through the green arrow in the gutter, I get the following error: image

"CMD.EXE was started with the above path as the current directory." The command also being run is npm.cmd exec ... instead of npm exec ...

I'm using the latest version of Vitest Runner (0.6.1) and on PhpStorm 2022.1

linux-china commented 2 years ago

Could you try this version? vitest-jetbrains-plugin-0.6.2.zip

HalfLife7 commented 2 years ago

I get a new error when running from the green arrow - 'Cannot run program "D:\Program Files\nodejs\npm" (in directory "\wsl$\Ubuntu-18.04\home\saber\Code\codenames"): CreateProcess error=193, %1 is not a valid Win32 application'

image

It would seem that the IDE is having trouble using the correct npm/node and is trying to use it from Windows instead of the WSL Ubuntu. I have my node/npm set to the one in WSL Ubuntu.

image

linux-china commented 2 years ago

I have no dev environment WSL. Please use following version and I use npm path from configuration now. vitest-jetbrains-plugin-0.6.2.zip

HalfLife7 commented 2 years ago

New error: Cannot run program "\home\saber.nvm\versions\node\v16.14.0\bin\npm" (in directory "\wsl$\Ubuntu-18.04\home\saber\Code\codenames"): CreateProcess error=2, The system cannot find the file specified

image

linux-china commented 2 years ago

the correct command should be "\home\saber.nvm\versions\node\v16.14.0\bin\npm.cmd" on WSL?

XiaNi commented 2 years ago

@linux-china i think problem here is not in command but in directory and way how you run command. i don't know how jetbrains handle those wsl calls, but maybe something like this could also work: wsl -d Ubuntu-18.04 \home\saber.nvm\versions\node\v16.14.0\bin\npx -- vitest run -t

XiaNi commented 2 years ago

or maybe just cut "\wsl${DISTRO_NAME}" out, and it will work

linux-china commented 2 years ago

or maybe just cut "\wsl${DISTRO_NAME}" out, and it will work

@XiaNi @HalfLife7 I build a new version with this way, and anybody can try it?

vitest-jetbrains-plugin-0.6.5.zip

XiaNi commented 2 years ago

strangely the same

Cannot run program "\home\xiani\.nvm\versions\node\v16.10.0\bin\npm" (in directory "\\wsl$\Ubuntu\home\xiani\_WORK\msa-3d\client"): CreateProcess error=2, The system cannot find the file specified
Shhu commented 1 year ago

Hi, i have the issue too with WSL2 image

Error running 'npx vitest run -t "return the player name" src/entities/Player.test.ts': Cannot run program "C:\Users\lowsc\AppData\Roaming\npm\npx" (in directory "\\wsl$\Ubuntu-20.04\home\yann\dev\poc"): CreateProcess error=193, %1 n’est pas une application Win32 valide

vitest plugin try to use my windows npm instead of wsl npm, despite the configuration in phpstorm : image

if i run it from the phpstorm runner it works : image

technimakri commented 1 year ago

Hello, running into this same issue using WSL. Is it possibly just the slashes causing the issue? Not sure how the IDE handles UNC paths. The plugin calls: \home\technimakri\.nvm\versions\node\v16.10.0\bin\npm rather than: /home/technimakri/.nvm/versions/node/v16.10.0/bin/npm