Tests not runnable on Linux
derekwsgray opened this issue · 26 comments
Describe the bug
While the extension will install, it does not activate automatically. Forcing it to turn on in the settings does not resolve it.
To Reproduce
Steps to reproduce the behavior:
- Install the extension
- Go to the "Testing" panel - note there are no controls to run tests (not enabled)
- Go to the extensions settings page, check the first checkbox to force enable it.
- Observe the green triangles appear, but they do not execute any tests.
Expected behavior
The extension should auto-detect vitest and enable itself. Clicking the green triangles should run tests.
Environment
- OS: Linux Mint 19.3 (Ubuntu-based)
- VSCode version: 1.67.1
- Vitest version: 0.10.1
- Vitest plugin version: 0.1.27
Additional context
Following up on thread started on Discord. Tried one or two attempted fixes published but the issue remains.
Tried building/testing this repo itself and the same error occurs.
Experiencing a similar issue on Fedora..
- Test Explorer Panel does not appear in UI
- manually enabling the plugin via
"vitest.enable": true
has not effect - vitest runs as expected via pnpm test..
Environment
OS: Fedora 36
VSCode version: 1.67.1
Vitest version: 0.12.6
Vitest plugin version: 0.2.2
Run Toggle Developer Tools
in the command palette, can you see any error with vitest? @md1440
@md1440 @derekwsgray can you reproduce the issue in this project? https://github.com/zxch3n/vitest-ext-basic-example
I installed Fedora 36 and ubuntu virtual machine. But I failed to reproduce this error on the example project above.
I cloned your test project and the vitest plugins loads, running tests with the plugin fails but succeeds when ran via cli. It throws the following errors in dev tools:
ERR [Extension Host] ERROR ERROR Unknown options: 'outputFile', 'run' - For help, run: pnpm help test
console.ts:137 [Extension Host] ERROR ERROR Unknown options: 'outputFile', 'run'For help, run: pnpm help test
` ERR [Extension Host] Error:
( Vitest should be configured to be able to run from project root )
Error when running
pnpm test /home/marc/vitest-ext-basic-example/add.test.ts --reporter=json --reporter=verbose --outputFile /tmp/vitest-report-jwd25.json --run
cwd: /home/marc/vitest-ext-basic-example
node: v17.8.0
env.PATH:
Log:
ERROR ERROR Unknown options: 'outputFile', 'run'`
For help, run: pnpm help test`
at x (/home/marc/.vscode/extensions/zixuanchen.vitest-explorer-0.2.3/dist/extension.js:35:42)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Lr.scheduleRun (/home/marc/.vscode/extensions/zixuanchen.vitest-explorer-0.2.3/dist/extension.js:25:94)
at Ec (/home/marc/.vscode/extensions/zixuanchen.vitest-explorer-0.2.3/dist/extension.js:44:4381)
at py (/home/marc/.vscode/extensions/zixuanchen.vitest-explorer-0.2.3/dist/extension.js:44:2984)
at o.$runControllerTests (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:83:227589)`
When trying with my project where the issue first occured, vitest plguin doesn't start at all, it's not showing in Developer Running Extensions and it shows no Err in Dev tools. Activating it manually via settings.json has seemingly no effect, it doesn't seem to start at all.
Hope this helps. Let me know if you'd need more assist with testing...
Addendum:
When toggling Vitest Watch Mode via command palette all works fine in your test project. When attempting the same in my project it throws:
Command'Vitest: Toggle Watch Mode
resulted in an error (command 'vitest.toggleWatching' not found.
@md1440 What does your script.test
look like in package.json? Is there ./node_modules/.bin/vitest
in your project? Did you change the extension's Command-Line config in user settings?
I made a patch in the pre-release version, can you switch to pre-release and check whether it works now?
In script.test I only call "test": "vitest".. I have updated to the pre-release version and it's throwing the following error in 3 test setups including your cloned sample project which actually did run fine yesterday. .bin/vitest is present in all projects:
`Error:
( Vitest should be configured to be able to run from project root )
Error when running
pnpm test /home/marc/vitest-ext-basic-example/add.test.ts --reporter=json --reporter=verbose --outputFile /tmp/vitest-report-5vt91.json --run
cwd: /home/marc/vitest-ext-basic-example
node: v17.8.0
env.PATH:
...
Log:
ERROR ERROR Unknown options: 'outputFile', 'run'
For help, run: pnpm help test`
Strange things are happening...
@md1440 try changing your vitest.commandLine
to pnpm test --
. It should be the same command-line users run vitest tests from a terminal/shell, with the ability to append extra arguments (by the extension at runtime). This setting is not expected to be global. It should be configured for each project
@md1440 @derekwsgray can you reproduce the issue in this project? https://github.com/zxch3n/vitest-ext-basic-example
I installed Fedora 36 and ubuntu virtual machine. But I failed to reproduce this error on the example project above.
Yes, the tests are still not runnable in that project. The output is just "The test did not record any output"
@derekwsgray What is your vitest.commandLine
setting? Can you try the pre-release version?
Yay! Thank you @zxch3n, that seems to have been the issue for me. Setting the vitest.commandLine to pnpm test --
instead of pnpm test
with the pre-release version resulted in everything working as supposed across all 3 test projects :) Appreciate your help and work!
Experience the same issue on MacOS with latetst VSCode version, also tried toggle command it says command does not exist.
- No UI in explorer.
- No effect of any vscode json setting for this extension.
@sujeet-agrahari Can you try reproducing the issue on https://github.com/zxch3n/vitest-ext-basic-example/?
@zxch3n It worked. Clone and ran that command. Thanks.
@derekwsgray What is your
vitest.commandLine
setting? Can you try the pre-release version?
It's empty. I wasn't aware I was supposed to fill that in. However, entering ./node_modules/.bin/vitest
didn't improve the situation.
(Using pre-release)
@derekwsgray Normally you don't need to fill in that, I thought there might be some misconfigure which would have caused your problem. I made some changes and add a script in https://github.com/zxch3n/vitest-ext-basic-example. Can you try that again?
Error:
( Vitest should be configured to be able to run from project root )
Error when running
./node_modules/.bin/vitest /home/dgray/dev/git/vitest-ext-basic-example/add.test.ts --reporter=json --reporter=verbose --outputFile /tmp/vitest-report-nwg1.json --run -t add
cwd: /home/dgray/dev/git/vitest-ext-basic-example
node: undefined
{
"System": {
"OS": "Linux 5.4 Linux Mint 19.3 (Tricia)"
},
"Binaries": {
"Node": {
"version": "16.13.2",
"path": "~/.nvm/versions/node/v16.13.2/bin/node"
},
"Yarn": {
"version": "1.22.18",
"path": "~/.yarn/bin/yarn"
},
"npm": {
"version": "8.1.2",
"path": "~/.nvm/versions/node/v16.13.2/bin/npm"
}
},
"IDEs": {
"VSCode": {
"version": "1.67.2",
"path": "/usr/bin/code"
}
},
"npmPackages": {
"vite": {
"installed": "2.9.9",
"wanted": "^2.9.9"
},
"vitest": {
"installed": "0.12.9",
"wanted": "^0.12.6"
}
}
}
Seems like the cause is that the spawned process cannot find node. Is vitest.nodeEnv
set in https://github.com/zxch3n/vitest-ext-basic-example under .vscode/settings.json? If not, can you try setting it as {"PATH": "~/.nvm/versions/node/v16.13.2/bin"}
Yes, it's set and already contains that path within it. If I edit it to contain only that path, I still get the same error as above.
@derekwsgray You restart VS Code after settings changes, right? Sorry, I don't have clues why this is happening on your machine, and I failed to reproduce this issue in all my environments.
Yes, was restarting.
Was node installed via nvm
in your environment?
Yes, I use nvm in all my machines