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

Vitest extension doesn't rerun tests when test files change #483

Open
4 tasks done
Igor-Vuk opened this issue Sep 30, 2024 · 19 comments
Open
4 tasks done

Vitest extension doesn't rerun tests when test files change #483

Igor-Vuk opened this issue Sep 30, 2024 · 19 comments

Comments

@Igor-Vuk
Copy link

Describe the bug

When test files change, Vitests extension doesn't rerun them. The only way to rerun tests files and get new data is to click "Refresh tests" and then "Run tests" on every change inside test files. In terminal tests are rerunning normally on files save. I uploaded a short video

tests.mp4

Reproduction

Write any type of tests and run them

Output

.

Version

1.2.12 published 2024-09-30

Validations

@olafure
Copy link

olafure commented Oct 1, 2024

Confirmed. I think this is related to #472 which was probably closed in error.
This is not an vscode error like someone suggested, since 1.0.7 works. I think 1.2.0 might be OK too.

@Igor-Vuk
Copy link
Author

Igor-Vuk commented Oct 1, 2024

just tried the latest release 1.2.13. Same thing. And there is no coverage report also.

@olafure
Copy link

olafure commented Oct 1, 2024

I don't know if it's the root cause, but

getFiles() {
is returning stale cache. If I create a new test file then it doesn't get included in the file list.

@neoscrib
Copy link

neoscrib commented Oct 1, 2024

My entire team has downgraded to version 1.2.6 to work around this issue. It has its own issues, but better than having to click the refresh button in test explorer after every little change to a test file or SUT file.

@LaurentMag
Copy link

i will add my voice here, its clearly an issue and having to reload at every change is not the most ideal thing..

@sheremet-va
Copy link
Member

Cannot reproduce with the reproduction you've provided. Note that you didn't fill the issue template correctly since the "Output" is empty.

Copy link

github-actions bot commented Oct 2, 2024

Hello @Igor-Vuk. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@sheremet-va
Copy link
Member

If I create a new test file then it doesn't get included in the file list.

This should be fixed by 6e2f2c4

@sheremet-va
Copy link
Member

sheremet-va commented Oct 2, 2024

In 1.2.15 I added some logs in the watcher if vitest.logLevel (can be configured in settings) is set to debug. If you cannot provide a reproduction, at least give me the output.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2024
@KirkJohnson
Copy link

I have 1.4.4 installed and this still happens. Everytime I had a new test to a test file I ran previously it doesn't recognize the test is there I have to reload in order for extension to recognize new test.

@ffMathy
Copy link
Collaborator

ffMathy commented Oct 12, 2024

We've had issues like this for ages. But I don't want to report it because there's no way I can make a repro, and so it'll just be closed.

Our developers have to reload VS Code like 10 times a day.

We are in the process of trying to switch to another test extension, but others are unstable too. We hope switching to Deno 2.0 will help, or perhaps even Bun when they finish their extension.

I hope someone finds a root cause. I wonder how many are secretly having this issue.

@sheremet-va
Copy link
Member

sheremet-va commented Oct 12, 2024

I will reopen this to keep track of the issue.

Our developers have to reload VS Code like 10 times a day

Just an FYI, you don't need to restart the extension, you can press "Refresh Tests" button

Screenshot 2024-10-07 at 15 33 32

You can help debug this issue by setting vitest.logLevel to verbose and reporting the output. If you don't have a reproduction, reporting the output still helps find the issue

@ffMathy
Copy link
Collaborator

ffMathy commented Oct 12, 2024

Refresh tests doesn't work for us. It simply doesn't do anything.

It does at first, but not after you've either run a test once or debugged a test once.

I'll try the debug option you provided to see if I can share more details.

@sheremet-va
Copy link
Member

The refresh button calls vitest.close - it's possible that it gets stuck waiting for the test to finish collecting or there is a hanging process with your setup. To collect the test, the extension actually runs the test files but doesn't execute the test functions. How long does it take to run this command with a single file in your repo: vitest run {name_of_the_test} -t '~~'? (Note that -t will make so that all tests are skipped).

@sheremet-va
Copy link
Member

sheremet-va commented Oct 12, 2024

1.6.0 adds an option vitest.experimentalStaticAstCollect to use AST parser to collect tests instead of running the files. This should help if your tests take a long time to import which causes a visible hang. This version also fixes a bug when watcher stopped working after pressing "Refresh Tests"

I wasn't able to reproduce the hanging "refresh tests" button yet even when there is an infinite loop in the test file 🤔

@ryaninvents
Copy link

This issue is affecting me using version 1.6.0. "Refresh tests" works for me, but it takes a while since there are many tests in our repo. "Continuous Run" does not work. If it helps, I'm in a pnpm monorepo, but the tests that I'm trying to use this extension for are all contained to one package (i.e. the test files and the code I am testing are all in the same package, and I'm trying to trigger a re-run by editing code in that same package).

I'll see if I can post a minimal repro later today.

@trydofor
Copy link

trydofor commented Oct 24, 2024

"Continuous Run" does not work.

for me, Start Continuous Run by step 1,2,3 works few time, or only at startup, the toggle of console.log line can be refreshed. and Refresh tests also works but takes long time.

  • pnpm monorepo
  • vitest.explorer 1.6.1
  • vitest 2.1.2
  • vscode 1.94.2

image

watching, but not refresh the test when toggling the line

[INFO 11:15:19 AM] Running 1 file(s) with name pattern: ^\s?map and object json map and obj$
[INFO 11:15:26 AM] Running 1 file(s) with name pattern: ^\s?map and object json map and obj$
[INFO 11:15:28 AM] [RUNNER] Watching test files: layers/common/tests/safe-converter.test.ts with pattern ^\s?map and object
[INFO 11:15:33 AM] Running 1 file(s) with name pattern: ^\s?map and object json map and obj$
[INFO 11:15:37 AM] [RUNNER] Watching test files: layers/common/tests/safe-converter.test.ts with pattern ^\s?map and object
[INFO 11:15:40 AM] Running 1 file(s) with name pattern: ^\s?map and object json map and obj$

@sheremet-va
Copy link
Member

If you have issues with this, I recommend enabling vitest.logLevel: 'verbose' and posting your "Output" here so I can analyse what goes wrong. I will need the whole Output, not just the part you think is relevant. I validate that the whole output is given by the first line (it prints the version of the extension and path to Node.js). If you think there is sensitive information there, you can replace it with **

@trydofor
Copy link

If you have issues with this, I recommend enabling vitest.logLevel: 'verbose' and posting your "Output" here so I can analyse what goes wrong. I will need the whole Output, not just the part you think is relevant. I validate that the whole output is given by the first line (it prints the version of the extension and path to Node.js). If you think there is sensitive information there, you can replace it with **

all output are these lines

[INFO 11:17:56 PM] [v1.6.1] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 11:18:00 PM] [API] Running Vitest v2.1.3 (common/vitest.config.ts) with [email protected]: ~/.asdf/shims/node 
[INFO 11:18:01 PM] [API] Running Vitest v2.1.3 (mobile/vitest.config.ts) with [email protected]: ~/.asdf/shims/node 
[INFO 11:18:28 PM] [API] Vitest v2.1.3 (mobile/vitest.config.ts) child process 44023 created
[INFO 11:18:28 PM] [API] Vitest v2.1.3 (common/vitest.config.ts) child process 43958 created
[INFO 11:18:29 PM] [VSCODE] Watching professional-razor with pattern **/*
[INFO 11:19:36 PM] [API] Collecting tests: layers/common/tests/safe-converter.test.ts
[INFO 11:19:42 PM] [TEST] <Suspense> is an experimental feature and its API will likely change.

[INFO 11:20:17 PM] Running 1 file(s) with name pattern: ^\s?safeSetArr
[INFO 11:20:32 PM] Running 1 file(s) with name pattern: ^\s?safeSetArr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants