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: Prevent null snapshots from being stored and causing errors #16015

Merged
merged 1 commit into from
Apr 15, 2021

Conversation

chrisbreiding
Copy link
Contributor

User facing changelog

  • Fixed an issue where hovering over a command log without a snapshot would cause the error Cannot read property 'name' of null

Additional details

Snapshotting can fail for various reasons. In the issue this closes, it was because the snapshot happens before the page fully loads, but it can also fail if the page is cross-origin. We catch such failures when creating the snapshot and return null, but the log adds that null value to the list of snapshots. When the user hovers over the command and we try to display the snapshot, it's expected to be a proper snapshot object and throws when we try to access properties on it. The solution is simply to not add null snapshots to the list of the log's snapshots. Then it's properly recognized as "missing" (which is correct, since we can't get a snapshot of it) and we display that to the user without erroring.

How has the user experience changed?

Hovering over commands with a missing snapshot no longer errors.

PR Tasks

  • Have tests been added/updated?
  • Has the original issue or this PR been tagged with a release in ZenHub?
  • N/A Has a PR for user-facing changes been opened in cypress-documentation?
  • N/A Have API changes been updated in the type definitions?
  • N/A Have new configuration options been added to the cypress.schema.json?

@chrisbreiding chrisbreiding requested a review from a team as a code owner April 15, 2021 15:47
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 15, 2021

Thanks for taking the time to open a PR!

@chrisbreiding chrisbreiding requested review from jennifer-shehane, kuceb and bahmutov and removed request for a team and jennifer-shehane April 15, 2021 15:47
@cypress
Copy link

cypress bot commented Apr 15, 2021



Test summary

9493 0 111 3Flakiness 1


Run details

Project cypress
Status Passed
Commit adc1813
Started Apr 15, 2021 4:00 PM
Ended Apr 15, 2021 4:13 PM
Duration 12:54 💡
OS Linux Debian - 10.8
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

cypress/integration/retries.ui.spec.js Flakiness
1 runner/cypress retries.ui.spec > opens attempt on each attempt failure for the screenshot, and closes after test passes

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

Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

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

Perfect, fixes my test case repo, when hovering shows "snapshot is missing", nice

Screen Shot 2021-04-15 at 12 51 44 PM

@bahmutov bahmutov self-requested a review April 15, 2021 16:52
Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

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

meant to approve it right away

@chrisbreiding chrisbreiding merged commit 0a63455 into develop Apr 15, 2021
@chrisbreiding chrisbreiding deleted the issue-15816-undefined-snapshot branch April 5, 2022 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undefined snapshot on test failure
2 participants