-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat: cy.intercept provides req.query. #16916
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
Conversation
Thanks for taking the time to open a PR!
|
Flaky failures. |
packages/driver/cypress/integration/commands/net_stubbing_spec.ts
Outdated
Show resolved
Hide resolved
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.
very nice work. LGTM once the docs PR is ready
cy.window().then((win) => { | ||
const xhr = new win.XMLHttpRequest() | ||
|
||
xhr.open('GET', '/users?someKey=someValue') | ||
xhr.send() | ||
}) |
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.
there is no need to do this btw, $.get
is available in this context and doesn't require scoping into cy.window().then()
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.
$.get
appends its own query member like _=12345
behind the scene. Because of that, we cannot use them for our tests.
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.
You can pass cache: true
to not do that
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.
It doesn't work with Firefox. I rolled it back.
Adding @mccataldo to review from a DX perspective |
User facing changelog
The incoming request object yielded to request handler functions passed to
cy.intercept()
(req
) now has areq.query
property, which is a getter/setter for the query parameters on the request URL.Additional details
query
,url
getter and setter toreq
object.How has the user experience changed?
Before:
req.query
=>undefined
.After:
req.query
=>{ a: 'b' }
PR Tasks
cypress-documentation
? => feat: cy.intercept provides req.query. cypress-documentation#3986type definitions
?