Repository navigation
feat(test-runner): Prevent loading files not in --test-list - #39743
Closed
danym (dany-mns) wants to merge 1 commit into
Closed
danym (dany-mns) wants to merge 1 commit into
danym (dany-mns) wants to merge 1 commit into
Conversation
Collaborator
|
danym (@dany-mns) Thank you for the PR! I don't think this is the right implementation for the feature - we should not load test list twice, and we should account for test list files somewhere in the loadUtils instead of overwriting testMatch. Also, please file an issue before sending a PR, according to the contributing guide. |
Collaborator
|
Closing as stale. See also #39901. |
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.
Summary
This PR modifies
--test-listto restrict file loading to only the files referenced in the test list, preventing Playwright from loading and evaluating files that aren't part of the current test run.Before this change
When using
--test-list, Playwright would:testMatchpatternThis caused crashes when test files not in the list had syntax errors, missing dependencies, or used deprecated APIs (e.g., bare
describe()from v1 syntax).After this change
When using
--test-list, Playwright now:testMatchwith only the files referenced in the listFiles not referenced in the test list are never loaded or evaluated.
Motivation
Problem: Crashes from unrelated broken files
In large monorepos with thousands of tests, it's common to have:
When running a subset of tests via
--test-list, these unrelated broken files would cause the entire test run to crash during file loading, even though they weren't being tested.Example crash scenario:
Solution
By restricting file loading to only test-list files, the test runner:
Technical Implementation
loadTestList()to expose the unique file list (1 line added inloadUtils.ts)runTests()to replaceproject.testMatchwhen--test-listis provided (4 lines added inprogram.ts)Test Coverage
Added new test:
--test-list should not load files not in the listFiles Changed
packages/playwright/src/runner/loadUtils.ts- Added.filesproperty toloadTestListreturn valuepackages/playwright/src/program.ts- Use files list to restricttestMatchtests/playwright-test/test-list.spec.ts- Added test for file loading restriction