-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
.cause
of errors innode:test
test cases not available to custom reporter
#48900
Comments
this seems to work for me on version |
also, nice work on https://github.com/voxpelli/node-test-pretty-reporter 🎉 |
In For some reason there is no longer a |
I am not sure what you mean? |
well the example used in this issue does seem to work: export default async function* customReporter(source) {
for await (const event of source) {
if (event.type === "test:fail") {
let err = event.data.details.error;
if (err.code === "ERR_TEST_FAILURE") {
err = err.cause;
}
yield "Outer error: " + err.message + "\n";
yield "Inner error: " + err.cause?.message + "\n";
}
}
} |
Support for the more standard way of doing it, the |
Version
18.16.1
Platform
MacOS
Subsystem
test
What steps will reproduce the bug?
I made a Code Sandbox that shows a reproduction.
In short:
Will log:
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
I expected the
.cause
(and other properties of theError
) to be available to the reporter and thus for the output of the above reproduction to be:What do you see instead?
Neither the
.cause
(or other properties I add to theError
) is available to the reporter and the output of the above thus is:I do see eg the
expected
property of anAssertionError
from Chai ornode:assert
carry through though, not sure why those are carried through but other properties are not.Additional information
Getting the full
cause
chain can be crucial in understanding an unexpected error.An error chain that's
Could not create DB
>Unable to connect to DB
><CONNECTION_ERROR>
needs all the parts to make sense, but right nownode:test
reporters are only able to show the topmost error,Could not create DB
.Similar PR in Mocha: mochajs/mocha#4829
Issue regarding adding support for this to my new reporter: voxpelli/node-test-pretty-reporter#2
The text was updated successfully, but these errors were encountered: