Skip to content
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: refactor cy.intercept internals to generic event-based system #15255

Merged
merged 21 commits into from
Mar 3, 2021

Conversation

flotwig
Copy link
Contributor

@flotwig flotwig commented Feb 26, 2021

  • Closes

User facing changelog

  • Reverted "The delayMs option for StaticResponses used with cy.intercept has been renamed to delay."

Additional details

How has the user experience changed?

PR Tasks

Sorry, something went wrong.

flotwig and others added 12 commits February 22, 2021 10:06

Verified

This commit was signed with the committer’s verified signature.
almeidx Almeida

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Partially verified

This commit is signed with the committer’s verified signature.
Jiralite’s contribution has been verified via SSH key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
This reverts commit d662c5d.

Had to revert this because it ends up creating an inconsistency in the APIs.
res.delay() is a function, which is why res.delayMs needs to be the scalar.
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 26, 2021

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Mar 1, 2021



Test summary

3979 0 49 2


Run details

Project cypress
Status Passed
Commit 51f464d
Started Mar 2, 2021 7:58 PM
Ended Mar 2, 2021 8:08 PM
Duration 09:45 💡
OS Linux Debian - 10.5
Browser Chrome 83

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

Comment on lines +16 to +18
'before:request': onBeforeRequest,
'response': onResponse,
'after:response': onAfterResponse,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the next step after this PR is to add request and before-response events here, and expose req.on to the user

@flotwig flotwig requested a review from chrisbreiding March 1, 2021 19:44
@@ -34,14 +36,16 @@ export const onRequestComplete: HandlerFn<NetEventFrames.HttpRequestComplete> =
if (isAwaitingResponse) {
// the user is implicitly expecting there to be a successful response from the server, so fail the test
// since a network error has occured
return failCurrentTest(err)
throw err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to check how this interacts with the latest error handling and ensure the right error is displayed.

I'm of the opinion now that, whenever possible, we should avoid re-throwing errors when we have already caught them and instead wrap them with the context where they're caught and report them via other means (like how failCurrentTest calls into cy.fail). There's a lot of older code that doesn't follow this pattern, but for new or changed code, it would be nice to have it do so.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After our pairing session, I added the reporter tests here: 41e0e79 (#15255)

There's still the issue with double-wrapping cy.intercept errors, in addition to cy.fail propagating to top in the reporter tests.

@@ -34,14 +36,16 @@ export const onRequestComplete: HandlerFn<NetEventFrames.HttpRequestComplete> =
if (isAwaitingResponse) {
// the user is implicitly expecting there to be a successful response from the server, so fail the test
// since a network error has occured
return failCurrentTest(err)
throw err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 5, 2021

Released in 7.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 5, 2021
@flotwig flotwig deleted the cy-intercept-events branch January 24, 2022 18:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants