-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
🚀 Feature Proposal
When running jest foo
, foo
should be matched against the path relative to package.json
instead of its absolute path.
Motivation
We have a test file user.spec.ts
, and accidentally running jest user
runs all tests, because the full path of all the test files starts with /Users/my-username/...
. It's also odd to run jest foo
and not see the string "foo" anywhere in the output
$ jest test /Users
RUNS src/index.spec.ts
RUNS src/author.spec.ts
RUNS src/book.spec.ts
Example
Pitch
This oddity is confusing behavior that should at least be documented. The current documentation says
When you run jest with an argument, that argument is treated as a regular expression to match against files in your project.
which is confusing if the regular expression can also match directories outside of my project. I can't think of a good reason to keep this behavior (why would you want a regex matching all of the test files in your project?)