fix: run gutter tests with the most specific config when several configs claim the same file - #803
Open
bennycode wants to merge 3 commits into
Open
Conversation
…igs claim the same file File items now collect the tags of every config that claims them (folder items already did), and run profiles are registered for all discovered configs before any process spawns, deepest config first. VS Code invokes the first registered profile that matches the item, so the most specific config becomes the effective default. Fixes vitest-dev#799
bennycode
force-pushed
the
fix/799-default-profile-selection
branch
from
August 6, 2026 15:42
e3fbd40 to
bd3dc7b
Compare
Author
|
Closing because the proposed change only makes all claiming profiles eligible; it does not change which profile VS Code selects by default and therefore does not resolve #799. |
bennycode
marked this pull request as ready for review
August 7, 2026 12:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #799
A shared base config like
vitest.config.base.tsmatches the extension'sconfigGlob, so it gets its own Vitest instance that claims the same test files as the package-level configs that merge it. The gutter "Run Test" button then runs tests with the base config, which is missing the merged options (tags,env, …):Why registration order alone doesn't fix it
@sheremet-va suggested in #799 to register the profiles in a different order so vscode picks up the more specific config automatically. I tried that first and on its own it changes nothing. A file item only gets the tag of the first config that resolves it (
getOrCreateFileTestItemreturns the cached item without touching its tags), and since profiles are tag-scoped, the shallowest config's profile is the only one VS Code can ever pick for that file, no matter the registration order.Fix
getOrCreateFolderTestItemalready does this for folder items. File items were the inconsistency: with two configs claiming the same directory, the folder item is runnable by both configs' profiles, but the files inside it only by the first one.The base config's profile stays available in the profile picker; only the effective default changes. Configs at the same depth behave as before.
Tests
Added
samples/shared-base-configand an e2e test that clicks the gutter run button. The sample test only passes under the package-level config (it asserts on anenvvalue), so the run result shows which config executed it:0/1before this change,1/1after.