fix(jest): emit --findRelatedTests with positional file args (fixes #2150, #1859)#2237
Open
just-jeb wants to merge 2 commits into
Open
fix(jest): emit --findRelatedTests with positional file args (fixes #2150, #1859)#2237just-jeb wants to merge 2 commits into
just-jeb wants to merge 2 commits into
Conversation
…2150, #1859) ng test --find-related-tests file1,file2 was emitting --findRelatedTests=file1,file2, which Jest interprets as a boolean flag with the value discarded, so no filtering happened. The README documents the comma-separated syntax as the builder's public API; the builder now translates both array and comma-string forms into Jest's positional-args calling convention. Adds unit tests for single file, comma-separated, multi-flag array, single-string and mixed-with-flag forms. Adds integration tests for the comma-separated form and a single-file form that genuinely verifies filtering (1 suite, 1 test).
…s for --findRelatedTests The findRelatedTests describe block in options-converter.spec.ts checked the internal CLI array returned by convertToCliArgs — an implementation detail. Three integration tests in integration.js already cover the behavioral outcome: Jest receives positional file args and finds only the related specs. Remove the redundant unit assertions so the test suite reflects observable user behavior.
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.
PR Checklist
PR Type
What is the current behavior?
ng test --find-related-tests file1,file2(the form documented inpackages/jest/README.md:193) emits--findRelatedTests=file1,file2to Jest. Jest treats--findRelatedTestswith an=value as a boolean flag and drops the value, so no filtering happens.The array form (
findRelatedTests: ['file1', 'file2']) emits--findRelatedTests file1 --findRelatedTests file2. That happens to work because each repeated--findRelatedTestsenables the mode and each value becomes a positional, but it's accidental — re-listing the flag isn't the documented contract.Issue numbers: #2150, #1859. Re-implements the fix from the closed #2185.
What is the new behavior?
A
POSITIONAL_ARRAY_OPTIONSset inoptions-converter.tsflags Jest options that take positional file args.findRelatedTestsis the only one today. The converter:--findRelatedTeststo the flag listBoth
findRelatedTests: 'file1,file2',findRelatedTests: ['file1,file2'], andfindRelatedTests: ['file1', 'file2']now produce[--findRelatedTests, file1, file2].Unit tests in
options-converter.spec.tscover single file, comma-separated, multi-flag array, single-string, mixed-with-other-flag, and doubled-comma forms.Integration tests in
packages/jest/tests/integration.js:multi-project-find-related-commaexercises the comma form documented in the README.multi-project-find-related-singleactually verifies filtering (1 suite, 1 test). The pre-existing test with two source files was a false-green — the library has exactly two specs, so even broken filtering still produced "2 suites".Does this PR introduce a breaking change?
Pre-existing array form keeps producing the same positionals, just emitted via the new positional-args code path. The previously-broken comma form now works.
Other information
N/A