vitest-dev / vscode

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

feat: use Vitest public API instead of Vitest CLI #253

Closed sheremet-va closed 6 months ago

sheremet-va commented 7 months ago

This PR switches to use public Vitest API instead of calling vitest CLI directly. Improvements that come with it:

Known issues

ffMathy commented 6 months ago

Very exciting stuff! Looking forward to this!

oenu commented 6 months ago

Excited to see this get merged

@ me if you'd like a review

ffMathy commented 6 months ago

Excited to see this get merged

@ me if you'd like a review

Yeah same! I check back every time there's a new commit 😍

ffMathy commented 6 months ago

Hmm, how is the continuous mode supposed to run if enabled for individual files? Will this work also? If so, how?

image
sheremet-va commented 6 months ago

Hmm, how is the continuous mode supposed to run if enabled for individual files? Will this work also? If so, how?

image

Good question. Currently it only supports a single test block/describe block I think (but multiple files is fine), but it should be possible to have multiple test/describe blocks, we can just merge them into a single regexp.

ffMathy commented 6 months ago

Hmm, how is the continuous mode supposed to run if enabled for individual files? Will this work also? If so, how?

image

Good question. Currently it only supports a single test block/describe block I think (but multiple files is fine), but it should be possible to have multiple test/describe blocks, we can just merge them into a single regexp.

Awesome - will this be solved as part of this PR also, or?

sheremet-va commented 6 months ago

Awesome - will this be solved as part of this PR also, or?

Yeah, should be possible. I made it so it runs tests correctly now, but it doesn't report the result because the test run uses a different request. I need to think more about the architecture there (already have some ideas). This PR should be merged this week after we release locations in Vitest, and I will publish it with a beta tag, so everyone can join in.

ffMathy commented 6 months ago

Awesome! 😍 Can't wait! Thanks for the status update.

Can you elaborate on what you mean by the request being different? Maybe me/others could then chime in with architecture proposals and/or ideas.

ffMathy commented 6 months ago

Awesome! How can I try this? :heart:

ffMathy commented 6 months ago

Context:

image
sheremet-va commented 6 months ago

Yes, I know. I am rewriting our release script. Please be patient and just wait.

sheremet-va commented 6 months ago

Released as 0.5.0 (we are using VSCode convention for pre-releases, not semver). Should be available to install if you switch the extension to a pre-release version:

Screenshot 2024-03-15 at 14 44 38

Feel free to close affected issues and open new ones 😄

chriswheeldon-peakon commented 6 months ago

Hi @sheremet-va, just posting this here rather than making an issue as I didn't know if you wanted bug reports from the pre-release yet (having only just landed it!). I was curious to try it out with https://github.com/chriswheeldon-peakon/vitest-workspace-cwd but the extension fails to load with:

2024-03-15 14:27:52.495 [error] Activating extension vitest.explorer failed due to an error:
2024-03-15 14:27:52.495 [error] Error: Attempted to insert a duplicate test item ID /Users/jbloggs/code/vitest-workspaces
    at Object.replace (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:138:24636)
    at Ge.reset (/Users/jbloggs/.vscode/extensions/vitest.explorer-0.5.0/dist/extension.js:7:1888)
    at Tt.defineTestProfiles (/Users/jbloggs/.vscode/extensions/vitest.explorer-0.5.0/dist/extension.js:7:5932)
    at async Tt.activate (/Users/jbloggs/.vscode/extensions/vitest.explorer-0.5.0/dist/extension.js:7:7329)

This is a monorepo with multiple vite.config.ts files (one in each package).

sheremet-va commented 6 months ago

Please, create a separate issue with a reproduction. This PR is not a place to follow all bugs with the current implementation.

We specifically released it as a pre-released to find all edge cases (like yours).