docs: clarify test file discovery prioritisation behavior #226
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.
The existing documentation stated that test files "can either be" in the root directory or test folder, which I interpreted as both could be used simultaneously. However, the actual behavior prioritizes root files and completely ignores the test directory when both exist.
Solution
This PR clarifies the test file discovery behavior by adding detailed explanations of the priority order and providing clear guidance on how to handle multiple test locations, preventing others from experiencing the same confusion I encountered.
Key Changes
1. Enhanced "Order of Operations" Section
--filesflag)2. Updated "Test Directory" Configuration Section
3. Enhanced CLI Documentation
--filesflag documentation with practical exampleDetailed Changes
Order of Operations Section
Test Directory Section
Now you can put all your test files in the `my-test-dir` directory. + **Note**: The test directory is only used when no test files are found in the project root. If you have both root-level test files (like `index.test-d.ts`) and a test directory, only the root files will be executed. See [Order of Operations](#order-of-operations) for more details.CLI Documentation
My Workaround
After discovering this behavior, I solved my issue by using the
--filesflag to explicitly specify all test locations:This allowed me to run both my root-level test file and all tests in my test directory as I originally intended.
Benefits
Validation
Impact
This documentation improvement addresses the exact confusion I experienced and will help other TypeScript library authors avoid the same issue. The changes maintain backward compatibility while significantly improving the user experience through better documentation clarity.