-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: resolves correctly specPattern #21057
fix: resolves correctly specPattern #21057
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
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 |
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.
One recommendation and one general question
}) | ||
|
||
cy.get('[data-cy="config-code"]').within(() => { | ||
cy.get('.bg-gray-50').contains('cypress/e2e/**/*.cy.{js,jsx,ts,tsx}') |
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 wonder if these should be data selectors, like [data-cy-config="resolved"]
. I do not like using CSS much for test selectors, it's super hard to read and tends to be brittle. What do you think?
packages/server/lib/config.ts
Outdated
|
||
// As we normalize the config based on the selected testing type, we need | ||
// to do the same with the default values to resolve those correctly | ||
defaultsForRuntime = { ...defaultsForRuntime, ...defaultsForRuntime[options.testingType] } |
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.
Interesting - kind of surprised we need to do this, I thought this was a UI only bug - so was the bug more deeper in the system, too?
The config stuff is so spread out all over the place, probably why we have some many bugs around it :(
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.
+1 all configuration things should prob be happening in the config package to keep this logic in one place and so we can make it easily testable.
packages/server/lib/config.ts
Outdated
|
||
// As we normalize the config based on the selected testing type, we need | ||
// to do the same with the default values to resolve those correctly | ||
defaultsForRuntime = { ...defaultsForRuntime, ...defaultsForRuntime[options.testingType] } |
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.
defaultsForRuntime = { ...defaultsForRuntime, ...defaultsForRuntime[options.testingType] } | |
defaultsForRuntime = { | |
...defaultsForRuntime, | |
...defaultsForRuntime[options.testingType] | |
} |
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.
Below we spread these values with the ignore type. Was the config overriding the default resolved values?
Are we able to add a unit test for this?
EDIT: talked offline, looks like it was stomping on itself.
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.
_.defaultsDeep(config, defaultsForRuntime)
is updating the config with the default, including the nested types which are totally correct, but the issue comes here config = setResolvedConfigValues(config, defaultsForRuntime, resolved)
because, at that moment config
has the nested type merged with the top level, but the nested fields as specPattern
do not exist on top-level, so defaultsForRuntime
does not include it unless we merge the testing type with the top-level ones, and when we try to search for the resolved one, it does not exist on the top-level (the default) so we assume it was coming from users config
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 the quick follow up... ✔️
packages/server/lib/config.ts
Outdated
// As we normalize the config based on the selected testing type, we need | ||
// to do the same with the default values to resolve those correctly | ||
defaultsForRuntime = { | ||
...defaultsForRuntime, | ||
...defaultsForRuntime[options.testingType], | ||
} |
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.
imo, this logic would be more suitably moved to packages/config/src/index.ts
where getDefaultValues
is defined. this is the only usage of that function, so IMO it would make sense to confine this logic to the config
package. what do you think @estrada9166 ?
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.
Sounds good! yeah, I'm gonna update it!
…e-config * 10.0-release: fix: make error on integration folder point to e2e (#20853) fix(unify): Update Cypress Dashboard Service Link in Login Modal (#21084) chore: fix windows node_modules install step (#21098) fix: webpack integration tests for app w webpack-dev-server-fresh (#21093) fix: move non spec files on migration (#21054) Bumping electron version in root chore(deps): Bumping electron dependency to 15.5.1 (#21072) fix: resolves correctly specPattern (#21057) feat: replace reconfigure button on settings page with link to config doc (#21077) feat(launchpad): update CT setup and config scaffolding (#20893) fix: cy.type('{enter}') on <input> elements submits the form correctly after Firefox 98. (#21042) chore: making the npm deps for vue, react, and vue2 use 0.0.0-dev (#21081) fix(cli): show additional mitigation steps for max path length error (#21047) fix: Plugin error when sending on disconnected IPC channel (#21011) chore: add internal types for cy.session command (#21028) chore: Update Chrome (stable) to 100.0.4896.88 (#21043)
User facing changelog
The default
specPattern
was being resolved as it was coming from the user config file which was incorrect; the reason why it was being resolved from the config file was that when trying to search for the default value, it was never found because it was nested in the testing type - and we are merging the testing type into the top-level config, creating a mismatch between the defaults values and the config itselfBefore
After
Additional details
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?