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.
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: add Cypress.Commands.overwriteQuery #25674
feat: add Cypress.Commands.overwriteQuery #25674
Changes from 4 commits
4802ab9
27c666a
9eaa132
151a71f
bc6b29c
621c5d8
2890d70
58e19c7
2e2b77a
1327452
4b2f7aa
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why wouldn't this logic be 1:1 with add command beyond the error handling and using
addQuery
?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.
The main difference is that queries don't have the concept of "parent/child" built into the API the same way that non-query commands do.
The call signature of a parent command is
fn(...args)
(not accepting a subject at all), while a child command isfn(subject, ...args)
(taking the subject as the first argument).All queries use the signature of
fn(...args)
, so we get to skip the conditional check of slicing the subject off ofargs
- it's never there, and the args require no manipulation.The other difference that the
commands
object storescommands[name] = { name, fn, type, prevSubject }
whilequeries
stores onlyqueries[name] = fn
.This is because when a command is overwritten, it needs to maintain the same
type
andpreviousSubject
values as the original; queries have neither of these, and all we need to create the overwrite is the original function.