Skip to content

Commit

Permalink
Slack: Handle a failure without a failure message
Browse files Browse the repository at this point in the history
The message attribute of `<failure>` is optional and some tools print the message in the textContent. We shouldn't output `undefined` if it's not present.

See test-results-reporter/parser#73 for the root issue
  • Loading branch information
mnoorenberghe committed Jul 10, 2024
1 parent a826f53 commit c01b416
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/targets/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ function getFailureDetails(suite) {
for (let i = 0; i < cases.length; i++) {
const test_case = cases[i];
if (test_case.status === 'FAIL') {
text += `*Test*: ${test_case.name}\n*Error*: ${truncate(test_case.failure, 150)}\n\n`;
text += `*Test*: ${test_case.name}\n`;
if (test_case.failure) {
text += `*Error*: ${truncate(test_case.failure, 150)}\n`;
}
text += '\n';
}
}
return {
Expand Down

0 comments on commit c01b416

Please sign in to comment.