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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Display Error's cause when test has failed #12999

Closed
Nokel81 opened this issue Jul 7, 2022 · 7 comments 路 Fixed by #13868
Closed

[Feature]: Display Error's cause when test has failed #12999

Nokel81 opened this issue Jul 7, 2022 · 7 comments 路 Fixed by #13868

Comments

@Nokel81
Copy link

Nokel81 commented Jul 7, 2022

馃殌 Feature Proposal

JS's Error class has recently been enhanced with native support for chaining instances together during construction using a second parameter and the { cause: parentErrorInstance } option.

It would be great if when a test fails because of a throw error the cause of the error would also be displayed.

Motivation

When wrapping errors the cause can give a lot of necessary information to help figure out why a test is failing

Example

N/A, this would just change the default formatter on test failure

Pitch

The changes to Error are part of the ECMAScript standard and are available in Node 16 so more people will start using them.

@SimenB
Copy link
Member

SimenB commented Jul 8, 2022

Agreed. We should also try to print all of an AggregateError's errors as well.

Do you wanna send a PR for this? Our error formatting mostly lives in https://github.com/facebook/jest/blob/fd4bfbdb1f8f7620c9da543bd68c2251bd347cdb/packages/jest-message-util/src/index.ts

@Nokel81
Copy link
Author

Nokel81 commented Jul 20, 2022

I have tried looking at the code in that file but am having trouble understanding how it fits into error causes stuff it seems to be just trying to parse already formatted stack traces.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Aug 19, 2022
@Nokel81
Copy link
Author

Nokel81 commented Aug 19, 2022

This is still relevant

@SimenB SimenB added Pinned and removed Stale labels Aug 19, 2022
@SimenB
Copy link
Member

SimenB commented Aug 19, 2022

Wanna send a PR? 馃檪

@SimenB
Copy link
Member

SimenB commented Feb 15, 2023

https://github.com/facebook/jest/releases/tag/v29.4.3

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants