-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Option to disable built-in enhanced formatting of Node AssertionError #8728
Comments
Side note: It's almost possible to get rid of the enhanced formatting, by using a custom environment to get rid of every part of the formatted error message prior to In practice this doesn't quite work cleanly, because the actual error message is full of chalk formatting codes around every line, so the necessary string manipulation becomes a lot harder. |
Also stumbled over this at some point and had to make https://github.com/spockjs/spockjs/blob/master/packages/assertion-post-processor-regular-errors/src/index.ts |
Another possibility would be to add the original error as a property of the custom message object. This would make it easier for a custom environment to cleanly undo the enhanced formatting. |
I added Internally, |
Right, so you really just need it in the reporter. At that point, we might consider supporting it in the built-in reporter as well |
If I could keep using the default reporter, and just set a reporter option to tell it to use the original |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
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. |
🚀 Feature Proposal
It should be possible to disable Jest's built-in handling of Node's
AssertionError
, to allow better integration with other tools that also enhance assertion error messages.Motivation
I've been trying to configure Jest and
power-assert
to work well together, so that I can useassert
in my code and tests, and seepower-assert
's enhanced output when running tests under Jest.The biggest obstacle is that Jest already has special enhanced handling of
AssertionError
failures. Normally that's good, but when combined withpower-assert
it means that Jest's (understandably) less-useful enhanced output takes priority, and the more-usefulpower-assert
output gets pushed down and is harder to see.It would therefore be nice to have the option to disable the Jest-side enhancement, and have it treat
AssertionError
in the same way as all other errors.Example
When the user enables
power-assert
support in their Jest and Babel configuration, they would also choose to disable Jest's special treatment ofAssertionError
, to give more helpful test failure output.Pitch
The enhanced output is built into
jest-circus
(and the Jasmine runner). Custom environments can't cleanly undo the enhancements, and there's currently no reasonable way to opt out of them.The text was updated successfully, but these errors were encountered: