fix: honor user-supplied test.root instead of clobbering it#37
Draft
gaurav-rk9 wants to merge 1 commit into
Draft
fix: honor user-supplied test.root instead of clobbering it#37gaurav-rk9 wants to merge 1 commit into
gaurav-rk9 wants to merge 1 commit into
Conversation
2492f7f to
c808c4e
Compare
The generated vitest config unconditionally set `config.test.root` to the generated config's directory (the target's package dir), discarding any `test.root` set in the user's config. Now an explicit `test.root` in the user config is honored (relative values resolved against the user config file's directory, as Vitest would). When `test.root` is not set, it still defaults to the generated config's directory, so the default behavior is unchanged. Coverage `include` globs resolve against the effective root, with a warning when covered sources fall outside an explicit root (Vitest silently drops such globs). Adds cases 13-15 covering an explicit relative test.root, coverage with a subdirectory config, and coverage with an explicit root.
c808c4e to
2b5e416
Compare
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.
Problem
The generated Vitest config unconditionally set
config.test.rootto the generated config's directory (the target's Bazel package dir), discarding anytest.rootset in the user's config:So an explicit
test.rootin a user config had no effect.Fix (scoped to honoring an override; default unchanged)
test.rootin the user config is now honored; a relative value is resolved against the user config file's directory, matching Vitest's own behavior.test.rootis not set, it still defaults to the generated config's directory (the package dir) — default behavior is unchanged.includeglobs resolve against the effective root. Because Vitest silently drops include globs outsidetest.root(allowExternal: false), a warning is emitted when covered sources fall outside an explicit root, rather than silently producing empty coverage.Tests
test.root; proves the user value is honored and discovery (--dir) stays independent of root.test.root(e2e).All existing tests plus the new cases and coverage e2e pass locally.