vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
740 stars 83 forks source link

New extension always watches files even if continuous mode is not enabled #290

Closed sheremet-va closed 6 months ago

sheremet-va commented 6 months ago

Describe the bug

Vitest reruns tests on every change and doesn't show the results in the interface which pushes pressure on the CPU.

Vitest provides watchTests API that we need to call whenever we receive a TestRunRequest that supports continuous mode:

function runTests(tests, continuous?) {
  if (continuous) {
    vitest.watchTests(tests)
  } else {
    vitest.watchTests(['non-existing']) // so watcher never triggers a rerun for these files unless we run them manually
  }
}

Reproduction

https://stackblitz.com/fork/github/vitest-dev/vitest/tree/main/examples/basic?initialPath=__vitest__/

System Info

Any

Used Package Manager

npm

Validations

sheremet-va commented 6 months ago

We need to collect tests when the file changes. The current implementation imports the file on every change to collect tests, but it doesn't run the tests themselves.