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

fix(unify): Do not screenshot or trigger the failed event when tests are skipped #19279

Merged
merged 8 commits into from
Dec 10, 2021

Conversation

ryanthemanuel
Copy link
Collaborator

@ryanthemanuel ryanthemanuel commented Dec 6, 2021

User facing changelog

Tests that are skipped within then blocks will no longer throw errors causing the test to fail. Tests that are skipped outside of then blocks will no longer trigger the fail event. This will prevent screenshots from happening from errors thrown by the fail event.

Additional details

When a test is skipped, mocha triggers a "sync skip; aborting execution" error. In investigating #17660, it was determined that #14867 had the same root cause. The main difference is that #17660 deals with synchronous tests and #14867 deals with asynchronous tests. In both cases, the fix is to update the failure handling to check if the test is pending (mocha's indicator that the test was skipped) and not fail in that scenario.

How has the user experience changed?

#17660 Before:

image

#17660 After:

image

#14866 Before:

image

#14866 After:

image

PR Tasks

  • Have tests been added/updated?
  • [na] Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?
  • [na] Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 6, 2021

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Dec 6, 2021



Test summary

8502 1 105 0Flakiness 1


Run details

Project cypress
Status Failed
Commit a0c36a9
Started Dec 9, 2021 9:18 PM
Ended Dec 9, 2021 9:30 PM
Duration 11:48 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


Failures

cypress/integration/commands/net_stubbing_spec.ts Failed
1 network stubbing > intercepting request > should delay the same amount on every response

Flakiness

cypress/integration/commands/net_stubbing_spec.ts Flakiness
1 network stubbing > waiting and aliasing > can timeout incrementally waiting on requests

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

@ryanthemanuel ryanthemanuel marked this pull request as ready for review December 6, 2021 20:33
@@ -1205,6 +1205,12 @@ export default {
// else just return ret
return ret
} catch (err) {
// If the runnable was marked as pending, this test was skipped
// go ahead and just return
if (runnable.isPending()) {
Copy link
Member

Choose a reason for hiding this comment

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

What specifically is erroring in the above try block? Could we check is pending up there and return instead of relying on the try block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mocha is actually throwing the error: https://github.com/mochajs/mocha/blob/ac43029d6a86150a48ccd59e50e89ca10c72a9c0/lib/runnable.js#L143

I don't believe there's a way we could catch it earlier than this as it's being triggered directly from the test being executed here: https://github.com/cypress-io/cypress/pull/19279/files#diff-231d74866a51e1411d172ab6ca0658f7fa712e9676f216ba797c544c47dcbf94R1144

mjhenkes
mjhenkes previously approved these changes Dec 8, 2021
@chrisbreiding
Copy link
Contributor

@ryanthemanuel Does this also fix this user's case? If so, I think we should add a test covering that. Probably need tests covering it.skip('test', () => {}) in addition to this.skip() in any case.

@ryanthemanuel
Copy link
Collaborator Author

@ryanthemanuel Does this also fix this user's case? If so, I think we should add a test covering that. Probably need tests covering it.skip('test', () => {}) in addition to this.skip() in any case.

Good catch @chrisbreiding I added the test case and ensured that snapshots actually would be generated in this case. Previously they were not due to configuration for the driver tests. I was unable to recreate the issue described here

chrisbreiding
chrisbreiding previously approved these changes Dec 9, 2021
Copy link
Contributor

@chrisbreiding chrisbreiding left a comment

Choose a reason for hiding this comment

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

Looks good 👍 It's just a nitpick, but I prefer not to prefix every test title with 'should'. Just ends up being a bit redundant.

@ryanthemanuel ryanthemanuel merged commit 0f0d10c into 10.0-release Dec 10, 2021
@ryanthemanuel ryanthemanuel deleted the issue-17660-fix-errant-screenshot-on-skip branch December 10, 2021 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants