-
Notifications
You must be signed in to change notification settings - Fork 76
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
Added includeStackTrace configuration option #161
Added includeStackTrace configuration option #161
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made those couple changes here
e7e9f04
test/htmlreporter.spec.ts
Outdated
expect(reportContent).toBeDefined(); | ||
expect(reportContent!.toString().indexOf("at stack trace")).toBe(-1); | ||
}); | ||
it.only("should keep stack trace in failure messages if set to true", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.only
probably blocks the rest of the tests in the suite here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! I must have forgotten to remove it while testing 🙏
took me a while to get my head around what's going on /////// htmlreporter.ts:394
// Test Failure Messages
if (
test.failureDetails &&
test.failureDetails.length > 0 &&
this.getConfigValue("includeFailureMsg")
) {
const failureMsgDiv = testResult.ele(
"div",
{
class: "failureMessages",
},
" "
);
test.failureDetails.forEach((err: Error) => {
failureMsgDiv.ele(
"pre",
{ class: "failureMsg" },
this.sanitizeOutput(err.message)
);
});
} |
src/htmlreporter.ts
Outdated
test.failureMessages | ||
.map((failureMsg) => | ||
!this.getConfigValue("includeStackTrace") | ||
? failureMsg.split("at")[0].trim().replace(/\n+$/, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #161 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we use failureDetails instead?
@StefanPuia I get your idea. However, as far as I can see
I cannot see the stack trace in there either, which is the main reason of this PR: to hide/show the stack trace. And in the end: doing this yields the same result as using |
My bad, I only included the replacement for the current version. For this issue specifically we'd just have to replace I suppose using
maybe something like this would work better? failureMsg.split(/\n\s+at/)[0].trim().replace(/\n+$/, "") |
Good point about the regex, and I totally agree. I will look at a more solid solution.
|
That's fair enough. |
IJestHTMLReporterConfig
type