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

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

Merged
merged 64 commits into from
Mar 15, 2024

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Feb 19, 2024

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

  • Requires Vitest 1.4.0 or higher
  • Faster test execution (instant feedback when clicking on "start")
  • Better continues mode integration
  • Support for "each" tests
  • Support in-source tests

Known issues

  • Currently, the extension requires vite.config or vitest.config file to function
  • The "continues" mode doesn't update test results if several test functions are selected - it will use the last one selected. For now, you can use continues mode on a file without problems
  • Sometimes debugger starts only on a second try
  • When using debugger, tests are not marked as "enqueued"
  • Update snapshot is not implemented, but button exists (does nothing)

@ffMathy
Copy link
Collaborator

ffMathy commented Feb 23, 2024

Very exciting stuff! Looking forward to this!

@sheremet-va sheremet-va added the p3-significant High priority enhancement (priority) label Feb 26, 2024
@sheremet-va sheremet-va changed the title feat: use Vitest public API to work with tests feat: use Vitest public API instead of Vitest CLI Feb 26, 2024
@sheremet-va sheremet-va force-pushed the feat/dynamic-worker-vitest branch from 6524cda to 67faa54 Compare February 26, 2024 19:08
@sheremet-va sheremet-va mentioned this pull request Mar 8, 2024
6 tasks
Copy link
Collaborator

@ffMathy ffMathy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that this is a draft PR, but thought it could be helpful already now with a preliminary review on a take-it-or-leave-it basis ❤️

Great work, and I can't wait to see this merged. I think it will help stabilize a lot ❤️

src/debug/startSession.ts Outdated Show resolved Hide resolved
src/debug/startSession.ts Show resolved Hide resolved
src/api.ts Outdated Show resolved Hide resolved
src/api.ts Outdated Show resolved Hide resolved
src/debug/startSession.ts Outdated Show resolved Hide resolved
src/debug/startSession.ts Outdated Show resolved Hide resolved
@sheremet-va
Copy link
Member Author

sheremet-va commented Mar 13, 2024

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
Copy link
Collaborator

ffMathy commented Mar 13, 2024

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.

@sheremet-va sheremet-va marked this pull request as ready for review March 15, 2024 12:09
@sheremet-va sheremet-va merged commit 0b70cb8 into vitest-dev:main Mar 15, 2024
1 check passed
@sheremet-va sheremet-va deleted the feat/dynamic-worker-vitest branch March 15, 2024 12:11
@ffMathy
Copy link
Collaborator

ffMathy commented Mar 15, 2024

Awesome! How can I try this? ❤️

@ffMathy
Copy link
Collaborator

ffMathy commented Mar 15, 2024

Context:
image

@sheremet-va
Copy link
Member Author

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

@sheremet-va
Copy link
Member Author

sheremet-va commented Mar 15, 2024

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
Copy link

chriswheeldon-peakon commented Mar 15, 2024

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
Copy link
Member Author

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

@vitest-dev vitest-dev locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-significant High priority enhancement (priority)
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants