-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat: CLI config
not supporting nested properties correctly
#20127
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
feat: CLI config
not supporting nested properties correctly
#20127
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
A number of tests are failing here on this branch, but I'm seeing the same failures in 10.0-release, and even develop when running locally - it feels like something changed with regards to cookies recently, perhaps a browser version upgrade? Going to put this as ready for review while I look into it, since I suspect the solution is unrelated to the changes in here. |
Without looking at the changes, could I run something like:
|
Yep! You have a mismatching brace in your example and probably need to quote it so bash doesn't munge the json, but it would work as:
...though one sec while I verify. Edit: Verified. Yes, the above example does work as expected. |
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.
Also, I resolved the conflicts - let's see if CI passes now.
I want to clarify: we use JSON for --config
, but the actual config is no longer JSON, but a JS module. Do you know if this has been discussed (stick w/ JSON on config, even if we are not using JSON for the cypress.config.js
. What about if they try to pass a key that's a function, like devServer
? I wonder if we should error.
I'm guessing this is something @cypress-io/dx has considered previously when thinking about cypress.config.js
?
@@ -595,6 +595,20 @@ describe('lib/util/args', () => { | |||
config: {}, | |||
}) | |||
}) | |||
|
|||
it('moves testing-type specific config options', function () { |
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.
Cool, looks good. Do we have a pre-existing pattern for if they pass invalid config, eg --config={blablah=false}
, or I think we just ignore these? It looks like we will inherit the same behavior with the hoisted keys, just wanted to clarify we do the same thing for the hoisted keys.
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.
I haven't touched the handling of invalid keys. The hoisting occurs via whitelist - we only pull keys from the breakingRootOptions
down into testing-type specific options, so if it's not whitelisted, we don't touch it here (and the same behavior as before will apply).
I haven't looked into exactly what that 'same behavior' is, but whatever it is, it'll still work! :D
We did discuss the Also, I believe we decided that function options would not be able to be specified via Does this make sense? Are there any issues with this? |
Not sure if this is relevant, but Windows cmd shell only understands |
Makes sense to me, and matches what was implemented in the PR, thanks for explaining. Just wanted to double check to make sure this was desired and intended.
No tests / docs using single quotes, provided here only as an example for discussion in the PR. |
|
||
// TODO: pass in options.config overrides separately, so they are reflected in the UI | ||
configFileContents = { ...configFileContents, ...testingTypeOverrides } | ||
configFileContents = { ...configFileContents, ...testingTypeOverrides, ...optionsOverrides } |
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.
Basically: The cli arg parsing lifts any testing-type specific args into e2e
, and then buildBaseFullConfig
puts them back in.
I went through probably half a dozen iterations on "why is baseUrl not getting set on the root config" before settling on this as the right place to put it, next to other code that already has the same purpose.
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.
thanks for clarification @cowboy, seems we are all good. Just need one more 👀 and ✔️ .
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.
This was something we discussed during the design of the CLI changes as per 10.0
In fact there is not supposed to be support for passing nested --config
values for e2e + component. They are supposed to be passed flattened for the testing type that you want applied.
So passing --config specPattern='...'
is only applied to the testing type you eventually go into and is applied to both testing types. You don't pass different configuration to different testing types.
It this is something we'd like to revisit I'm all ears - but it was intentionally designed this way. It's possible the existing implementation was not working correctly, but the aforementioned behavior was the desired behavior.
Edit
Sorry I just reread the comments throughout this PR and clearly others have chimed in with the same information. @BlueWinds what's not clear from this PR is what specific behavior this is fixing. When I first read this I saw the PR description regarding the config
not supporting nesting and assumed it was attempting to pass specific testing type config. What I'm looking for clarity on is what specific existing behavior is and what this PR is changing to the desired behavior. A simple before/after.
I tested this branch a bit more. This one isn't working for me unless I explicitly include # error - `specPattern` is not a valid configuration option
cd packages/driver
yarn cypress:run --config specPattern="**/*.spec.jsx"
# ok
cd packages/driver
yarn cypress:run --config specPattern="**/*.spec.jsx" --e2e As for the problem this PR solves @brian-mann, it's related to when you pass a JSON object to Before$ node ../../scripts/cypress run --e2e '--config={"specPattern": "**/*.spec.jsx"}'
`specPattern` is not a valid configuration option
https://on.cypress.io/configuration
`specPattern` is not a valid configuration option After$ node ../../scripts/cypress run --e2e '--config={"specPattern": "**/*.spec.jsx"}'
# works! |
Latchaln put this fairly clearly, so I'll refer you to his comment for a before / after. Currently in 10.0, most config values already work as you describe, getting included in whichever config type the user selects. The only ones that don't are those explicitly not available as root config values - eg, those in breakingRootOptions: This PR aims to allow those breakingRootOptions to be applied to the appropriate testing type(s) when passed in via --config. I'll update the PR description once I address @lmiller1990's findings above. |
It was checking to see what testing type the user had actually passed in, which, upon reflection, is not the correct action - we know what testingType This also means that if they run |
Updated PR with clear before / after examples. |
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.
Cool, seems good to me.
Seems like a legit failure in server-unit-tests: https://app.circleci.com/pipelines/github/cypress-io/cypress/32422/workflows/962760ee-0761-4d37-b915-8babc3bf8e5d/jobs/1284475 |
Fixed. |
* 10.0-release: chore: fix linting (#20388) feat(unify): rearrange settings (#20332) fix: make the glob groups work on windows fix: stop deleting files on install chore: fixing eslint duplicate imports fix(launchpad): scaffold correct config file (#20372) chore: Refactor Command Log UI (#20202) chore: fix launchpad's failing windows test (#20371) chore: UNIFY-860 remove all references to Cypress Cloud (#20369) chore: fix minor UI issues noticed in design review (#20251) feat: Sort browsers list alphabetically (#20248) fix: Improvements to Spec Pattern Rename "change" Modal (#20320) feat: CLI `config` not supporting nested properties correctly (#20127) fix: Relaunching app when Focus is pressed after app has closed (#20352)
User facing changelog
Can now pass in testing-type specific config options via
--config
without nesting JSON.Additional details
With the addition of more testing type specific config options, and especially with the requirement that
specPattern
be configured per testing type, using--config
via command line was a bit clunky, requiring a user to nest the config value.How has the user experience changed?
Before
After
This example resolves to the the config of
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?