Repository navigation
fix(search): a __tests__/ folder at the repository root counts as a test - #500
Merged
Merged
Conversation
isTestPath matched /__tests__/ only below another directory, so __tests__/foo.ts was taken for production code while src/__tests__/foo.ts was not. After upstream colbymchenry#2557 moved the dominant-file and explore filters onto isTestFile, the old start-of-path match for __tests__/ was lost.
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.
A file in a
__tests__/folder at the top of a repository is now treated as a test, as one belowsrc/or any other folder already was.Before,
isTestPathmatched/__tests__/only with a directory above it, so__tests__/foo.tswas taken for production code whilesrc/__tests__/foo.tswas not. Until upstream colbymchenry#2557 (merged in #499) this did not matter for the dominant-file and explore filters, which matched__tests__/at the start of a path with their own pattern; colbymchenry#2557 moved them ontoisTestFileand dropped that match. cubic flagged the gap on #499. The fix addslower.startsWith('__tests__/')beside the existingtests/,spec/ande2e/start-of-path checks.Verification, on head
2994ecc4d4d32f38053e82765552277da6a84023:__tests__/is-test-file.test.tsfails without the change (isTestFile('__tests__/foo.ts')was false) and passes with it, including a negative case (my__tests__/foo.tsstays production).tsc --noEmitandnpm run check:agent-docspass; the 25 test files that mentionisTestFile,isTestPath,scorePathRelevanceor__tests__/pass (576 passed, 1 skipped).is_test_path), unchanged here; this PR covers the TypeScript side only.README rows checked: none mention test-path detection, so none changed. The changelog entry is under
[Unreleased]and says to re-index projects with a top-level__tests__/folder, because index-time synthesizers also read this function (unmeasured).Summary by cubic
A file in a
__tests__/folder at the repository root now counts as a test, matching the behavior of such folders belowsrc/or any other directory.Previously
isTestPathmatched/__tests__/only when preceded by a directory, so__tests__/foo.tswas treated as production code. The fix addslower.startsWith('__tests__/')beside the existingtests/,spec/, ande2e/checks.my__tests__/foo.tsstays production.__tests__/folder should be re-indexed, since index-time synthesizers also read this function.Written for commit 2994ecc. Summary will update on new commits.
Summary by CodeRabbit
__tests__/files are now recognized as tests, matching nested test directories. They are excluded from production-code search and ranking and from main-routes file selection.__tests__/folder for the updated classification to take effect.