-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Current behavior:
cy.get(element).screenshot() displays a very confusing error if the element has zero height.
TypeError: Cannot destructure property `duration` of 'undefined' or 'null'.
The code that is causing the confusing error
numScreenshots ends up being zero when elPosition.height is zero.
| numScreenshots = Math.ceil(elPosition.height / viewportHeight) |
This causes _.last(results) to return undefined.
| _.last(results) |
Which causes takeScreenshot().then() to receive an undefined props parameter that it cannot destructure with { duration, path, size } = props;.
| { duration, path, size } = props |
Desired behavior:
cy.get(element).screenshot() should report an error that the element has zero height.
It is also extremely difficult to troubleshoot an error like this because bluebirdjs doesn't automatically log exceptions, so I have no idea where the code in the error message existed.
It appears that bluebirdjs has events for unhandled errors. It would be great if Cypress provided a filename and line number of the where the error is occurring in the Cypress log as well as a stack trace in the browser console.
http://bluebirdjs.com/docs/api/error-management-configuration.html
process.on("unhandledRejection", function(reason, promise) {
});
process.on("rejectionHandled", function(promise) {
});Steps to reproduce: (app code and test code)
You can recreate the confusing error message by trying to take a screenshot of a span with zero height.
cy.get('.zero_height_element').screenshot();Versions
Cypress 3.4.1
Ubuntu 16.04 & 18.04
