Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests not runnable on Linux #31

Closed
derekwsgray opened this issue May 10, 2022 · 26 comments
Closed

Tests not runnable on Linux #31

derekwsgray opened this issue May 10, 2022 · 26 comments
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@derekwsgray
Copy link

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:

  1. Install the extension
  2. Go to the "Testing" panel - note there are no controls to run tests (not enabled)
  3. Go to the extensions settings page, check the first checkbox to force enable it.
  4. 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.

Screenshots
image

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.

@derekwsgray derekwsgray added the p3-minor-bug An edge case that only affects very specific usage (priority) label May 10, 2022
@md1440
Copy link

md1440 commented May 16, 2022

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

@zxch3n
Copy link
Member

zxch3n commented May 17, 2022

Run Toggle Developer Tools in the command palette, can you see any error with vitest? @md1440

@zxch3n
Copy link
Member

zxch3n commented May 17, 2022

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

@md1440
Copy link

md1440 commented May 17, 2022

@zxch3n

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

@md1440
Copy link

md1440 commented May 17, 2022

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.

@zxch3n
Copy link
Member

zxch3n commented May 18, 2022

@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?

@md1440
Copy link

md1440 commented May 18, 2022

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

@zxch3n
Copy link
Member

zxch3n commented May 18, 2022

@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

@derekwsgray
Copy link
Author

@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"

@zxch3n
Copy link
Member

zxch3n commented May 18, 2022

@derekwsgray What is your vitest.commandLine setting? Can you try the pre-release version?

@md1440
Copy link

md1440 commented May 19, 2022

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!

@sujeet-agrahari
Copy link

Experience the same issue on MacOS with latetst VSCode version, also tried toggle command it says command does not exist.

  1. No UI in explorer.
  2. No effect of any vscode json setting for this extension.

@zxch3n
Copy link
Member

zxch3n commented May 20, 2022

@sujeet-agrahari Can you try reproducing the issue on https://github.com/zxch3n/vitest-ext-basic-example/?

@sujeet-agrahari
Copy link

@zxch3n It worked. Clone and ran that command. Thanks.

@derekwsgray
Copy link
Author

derekwsgray commented May 24, 2022

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

@zxch3n
Copy link
Member

zxch3n commented May 24, 2022

@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?

@derekwsgray
Copy link
Author

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

@derekwsgray
Copy link
Author

{
  "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"
    }
  }
}

@zxch3n
Copy link
Member

zxch3n commented May 24, 2022

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"}

@derekwsgray
Copy link
Author

derekwsgray commented May 24, 2022

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.

@zxch3n
Copy link
Member

zxch3n commented May 24, 2022

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

@derekwsgray
Copy link
Author

Yes, was restarting.

@derekwsgray
Copy link
Author

Was node installed via nvm in your environment?

@zxch3n
Copy link
Member

zxch3n commented May 25, 2022

Yes, I use nvm in all my machines

@ngirardin
Copy link
Contributor

This looks like a duplicate of #88

@zxch3n
Copy link
Member

zxch3n commented Feb 9, 2023

close as #125 merged

@zxch3n zxch3n closed this as completed Feb 9, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests

5 participants