Filter non-JS files from require when using glob with --projects#5412
Filter non-JS files from require when using glob with --projects#5412cpojer merged 6 commits intojestjs:masterfrom
require when using glob with --projects#5412Conversation
This ensures `packages/*` catches folders & not README.md
require when using glon with --patterns
require when using glon with --patternsrequire when using glob with --projects
|
It was difficult to pin down which part of the code was ultimately responsible, as the glob So, because the list of projects are directly |
Codecov Report
@@ Coverage Diff @@
## master #5412 +/- ##
=======================================
Coverage 62.26% 62.26%
=======================================
Files 205 205
Lines 6925 6925
Branches 4 4
=======================================
Hits 4312 4312
Misses 2612 2612
Partials 1 1Continue to review full report at Codecov.
|
| // Ignore globbed files that cannot be `require`d. | ||
| if ( | ||
| fs.existsSync(root) && | ||
| !fs.lstatSync(root).isDirectory() && |
There was a problem hiding this comment.
should we just do a single lstatSync and try-catch it to avoid 2 separate IO operations?
There was a problem hiding this comment.
That's also a possibility. My take is:
-
--projectsis often single to double-digits of entries, whereas the difference between 1 lookup vs. 2 wasn't discernible in my testing. (I originally didn't have the directory check there) -
If there are any edge-cases that aren't accounted for, we'll have the opportunity to see & correct the error in the future, vs. it being silently ignored (& not running any tests for that directory).
…estjs#5412) * Add test for workspaces with a README.md in the root * Filter projects to directories & require-able files only This ensures `packages/*` catches folders & not README.md * Add reference to jestjs#5199 in CHANGELOG.md * Remove custom testDir
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Fixes #5199, where a monorepo with
packages/README.mdwas beingrequired as a config file due to the glob from--projects packages/*.This change filters out non-
require-able files.Test plan