New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: CLI filtering --spec when commas in glob pattern #19557
Conversation
Thanks for taking the time to open a PR!
|
I'm just realizing now that some snapshot tests are failing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hang-up The change has the unintended side effect of updating the value that is printed to CLI when showing what Cypress searched for in the specs. We'd like to maintain the original behavior or printing the original search value and not the found values (since this is already printed in the Specs heading).
Can you update the code to not change the value?
@jennifer-shehane The side effect should have been addressed :) |
I believe this solution will break the case where we have multiple globs or a mixture of globs and specific spec files. ie.
indicating that you want:
I think a better solution would involve escaping the comma and more complex parsing of the string than our current comma split. |
Hey @mjhenkes!
And running a mixture of 2 specs + 1 glob pattern:
seems to pick up the right specs to run. |
I dug into the code some more, The issue will arise when there is a square or curly bracket in t regular expression. If found the whole I believe the following string will fail for you (I have a different folder setup for my test repo so i can't be sure 😄 )
|
You're right! I've narrowed it down to a couple of possible scenarios (to make sure I'm not missing anything): const patterns = {
0: "cypress/integration/**/*", // 1 glob
1: "cypress/integration/spec1.spec.js", // 1 spec
2: "cypress/integration/spec1.spec.js,cypress/integration/spec2.spec.js", // 1 spec + 1 spec
3: "cypress/integration/spec1.spec.js,cypress/integration/glob/**/*", // 1 spec + 1 glob
4: "cypress/integration/spec1.spec.js,cypress/integration/{[!fix]*.spec.js,!(_unit)/**/[!fix]*.spec.js}", // 1 spec + 1 glob with lists & range
5: "{[!fix]*.spec.js,!(_unit)/**/[!fix]*.spec.js}", // 1 glob with lists & range
6: "cypress/{static,build/public,{src,src/increment}}/*.js", // nested ranges
7: "cypress/integration/{[!fix]*.spec.js,! (_unit)/**/[!fix]*.spec.js},cypress/integration/spec1.spec.js,cypress/integration/{[!fix]*.specs.js,!(_unit)/**/[!fix]*.specs.js}"
}; // 2 globs with lists & ranges + 1 spec I'll do a rewrite of the split logic to accommodate them :) |
@hang-up your spec test cases look pretty good, I don't think i have anything to add. |
108315b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
--spec
with glob pattern does not find spec files #16102User facing changelog
Enable comma separated glob pattern matching for CLI parameter
spec
. Fixes #16102Additional details
This PR aims at fixing a bug discovered since
v6.5.0
.When glob patterns were defined with at least one comma, the original implementation would assume that when parsed as a string, the
spec
argv could be split into an array.This assumption holds when the argv is a string of spec files to run:
--spec "cypress/integration/spec-1.spec.js,cypress/integration/spec-2.spec.js"
would give an array similar toUnfortunately in the case of comma separated glob pattern, we would end with erroneous paths:
--spec 'cypress/integration/{[!fix]*.spec.js,!(_unit)/**/[!fix]*.specs.js}'
would give an array similar toThis PR fixes this issue by performing a glob check before mapping the string to an array of spec paths.
How has the user experience changed?
Following the same file structure as defined in the issue ticket
Before
After
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?