-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
filter should exclude cwd
#3344
Comments
The filter is just I recommend just adding a slash to it. |
If you want to specify a directory to run, you can use |
A slash doesn't help because it still matches. The It still seems weird to me that what directory the project is held in should affect whether or not a filter matches as it makes filters behave differently on each user's machine. Without knowing the implementation, there's also a chance it might be more performant to build the filenames as relative to the cwd rather than absolute because when you search against them you'll be searching shorter strings (and they'll also take less memory and run GC less though that difference might be too small to matter). |
Just to get this right - this issue is about the test name filter being matched against whole path including the current working directory? It should only match against relative path from current working directory. Small demo:
# Runs only test/math.test.ts
$ pnpm run test math
# Runs all tests due to cwd path "/x/y/vitest-example-project"
# Instead should run only test/example.test.ts
$ pnpm run test example |
Describe the bug
I did
cd ~/src
and then did agit clone
of a Vitest project which has the commandvitest --run src
. Because my project was held in a directory namedsrc
, thesrc
filter matched all files rendering it useless. The filter should work the same regardless of where the user checks out the project because we don't know what the user's directory structure might be and we would otherwise have to list all directory names that they should avoid putting the project intoReproduction
Now edit
package.json
and change"test:unit": "vitest run",
to"test:unit": "vitest run src",
and dorm vitest.config.js
. When you runtest:unit
all tests should pass, but it will end up running some that live in thetest
directory because thesrc
directory is ignored, so some will failSystem Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: