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

Cypress prints (uncaught exception) undefined: undefined when promise rejects with a string #24915

Closed
geritol opened this issue Dec 1, 2022 · 3 comments · Fixed by #25059
Closed
Labels

Comments

@geritol
Copy link
Contributor

geritol commented Dec 1, 2022

Current behavior

When the app code rejects with a string:

  • developer console displays the error properly
  • cypress displays (uncaught exception) undefined: undefined and fails the test

Desired behavior

  • cypress displays the exact error cause (reject's string content) and fails the test

Test code to reproduce

https://github.com/geritol/cypress-bug-repro

Cypress Version

11.2.0

Node version

v16.18.1

Operating System

macOS 12.6

Debug Logs

No response

Other

No response

@geritol geritol changed the title Cypress does not print error when promise rejects with a string Cypress prints (uncaught exception) undefined: undefined when promise rejects with a string Dec 1, 2022
@mike-plummer
Copy link
Contributor

Hey @geritol , thanks for opening an issue! I can certainly see how that would be annoying - we do print the rejection with appropriate error message to the browser console, but you're right that we don't always parse out the correct message for the Cypress command log resulting in the "undefined: undefined" behavior. I'll go ahead and forward this enhancement on to the team, but there's no guarantee if/when they'll have bandwidth to dig into it.

In the interim, we always welcome open source contributions if you (or anyone else) if interested in taking a stab at this! I did a little investigation and it should be a fairly trivial issue for a first-time contributor. It appears that the logic in packages/driver/src/cypress/error_utils.ts needs to be updated - the logError function assumes that the uncaught error is an Error object, but in this case it's a string. The logic building the message string needs to be updated to detect whether the err param is a string and if so use that as the message, then add/update tests as needed

@mike-plummer mike-plummer added type: enhancement Requested enhancement of existing feature good first issue Good for newcomers labels Dec 7, 2022
@emilyrohrbough emilyrohrbough added type: bug routed-to-e2e and removed type: enhancement Requested enhancement of existing feature labels Dec 7, 2022
@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Dec 8, 2022
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Dec 19, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 19, 2022

The code for this is done in cypress-io/cypress#25059, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 20, 2022

Released in 12.2.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants