-
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(net-stubbing): fix waiting on responses with no-body status codes #9097
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 |
packages/network/lib/http-utils.ts
Outdated
const NO_BODY_STATUS_CODES = [204, 304] | ||
|
||
export function responseMustHaveEmptyBody (req: IncomingMessage, res: IncomingMessage) { | ||
return _.some([_.includes(NO_BODY_STATUS_CODES, res.statusCode), _.invoke(req.method, 'toLowerCase') === 'head']) |
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.
wow, some people write such interesting code just to avoid ||
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.
job security
@flotwig It appears that 302 POST's might also be grouped into this. See this failure when attempting to cypress-io/cypress-realworld-app@1b54220 Test to reproduce the issue: https://github.com/cypress-io/cypress-realworld-app/pull/676/files#diff-8781249f032a90ab825382873828906eed104c18c2a93d20e9de10b4872b0df6R143 |
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.
Works, verified against 304 in cypress-io/cypress-example-recipes#598
nice, i was able to reproduce this with a simple Funnily enough, if you intercept the redirect, it does work as-is: cypress/packages/driver/cypress/integration/commands/net_stubbing_spec.ts Lines 1274 to 1290 in c0e14ea
|
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.
nice
…to come in 6.1.0
* wip - convert cy.route to cy.http; remove cy.server; adjust to use JSON.parse() * fix delete bankaccounts route * fix empty list test using cy.http * wip - experiments * uncomment wait * reproduction and notes around cy.http issue with public transactions stub * set run mode to not retry * remove only * rename cy.http to cy.intercept * remove JSON.parse per cypress-io/cypress-example-kitchensink#458 * update to get user id if not 401 response * add glob-match to usersSearch for cy.intercept * wip - iterate * install nocache * configure routes not to cache (temporarily) * note about failing cy.intercept for POST /logout * adjust cy.intercepts; notes on open Cypress issues * update matching for stubbed public transactions * restore to substring match for mocked response * uninstall and remove nocache for routes since resolved in cypress-io/cypress#9097 * adjust to use response.statusCode for fix in cypress-io/cypress#9097 to come in 6.1.0 * update syntax and expectation * delete if-none-match request header to prevent cached results for cy.wait * update to use regex for cy.intercept url matchers; delete if-none-match request header to prevent cached results for cy.wait * update /notifications to delete if-none-match request header to prevent cached results for cy.wait * cleanup and remove if-none-match for all feed routes, but continues to return 304 * refactor to delete if-none-match for all routes in a global beforeEach * restore limit to 10 * update route matching to be exact * update to get url from response object * update to use response.statusCode * update transaction view spec to use response.statusCode * update intercepts to use minimatch * cleanup * cleanup * example of res.send fixture not returning fixture * add delay middleware for all mobile viewport tests * cleanup * cleanup * update mobile cy.intercept to throttle all routes * fix syntax error * update from throttle -> setThrottle * update matching for global intercepts * update path matching * update matching for global intercepts * update intercept matching * temporary disable throttling for mobile * fix patch matching * update matching for cy.intercept * wait for public transactions Co-authored-by: Amir Rustamzadeh <amir@cypress.io>
* wip - convert cy.route to cy.http; remove cy.server; adjust to use JSON.parse() * fix delete bankaccounts route * fix empty list test using cy.http * wip - experiments * uncomment wait * reproduction and notes around cy.http issue with public transactions stub * set run mode to not retry * remove only * rename cy.http to cy.intercept * remove JSON.parse per cypress-io/cypress-example-kitchensink#458 * update to get user id if not 401 response * add glob-match to usersSearch for cy.intercept * wip - iterate * install nocache * configure routes not to cache (temporarily) * note about failing cy.intercept for POST /logout * adjust cy.intercepts; notes on open Cypress issues * update matching for stubbed public transactions * restore to substring match for mocked response * uninstall and remove nocache for routes since resolved in cypress-io/cypress#9097 * adjust to use response.statusCode for fix in cypress-io/cypress#9097 to come in 6.1.0 * update syntax and expectation * delete if-none-match request header to prevent cached results for cy.wait * update to use regex for cy.intercept url matchers; delete if-none-match request header to prevent cached results for cy.wait * update /notifications to delete if-none-match request header to prevent cached results for cy.wait * cleanup and remove if-none-match for all feed routes, but continues to return 304 * refactor to delete if-none-match for all routes in a global beforeEach * restore limit to 10 * update route matching to be exact * update to get url from response object * update to use response.statusCode * update transaction view spec to use response.statusCode * update intercepts to use minimatch * cleanup * cleanup * example of res.send fixture not returning fixture * add delay middleware for all mobile viewport tests * cleanup * cleanup * update mobile cy.intercept to throttle all routes * fix syntax error * update from throttle -> setThrottle * update matching for global intercepts * update path matching * update matching for global intercepts * update intercept matching * temporary disable throttling for mobile * fix patch matching * update matching for cy.intercept * wait for public transactions Co-authored-by: Amir Rustamzadeh <amir@cypress.io>
User facing changelog
cy.intercept
.cy.intercept
unless dynamically intercepted.Additional details
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?