Skip to content

Commit

Permalink
Notifications: 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 11, 2024
1 parent b911239 commit 9e1fc65
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/targets/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function getFailureDetails(suite) {
for (let i = 0; i < cases.length; i++) {
const test_case = cases[i];
if (test_case.status === 'FAIL') {
text += `<b>Test</b>: ${test_case.name}<br><b>Error</b>: ${truncate(test_case.failure, 150)}<br><br>`;
text += `<b>Test</b>: ${test_case.name}<br><b>Error</b>: ${truncate(test_case.failure ?? 'N/A', 150)}<br><br>`;
}
}
return text;
Expand Down
2 changes: 1 addition & 1 deletion src/targets/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ 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*Error*: ${truncate(test_case.failure ?? 'N/A', 150)}\n\n`;
}
}
return {
Expand Down
2 changes: 1 addition & 1 deletion src/targets/teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function getFailureDetailsFactSets(suite) {
},
{
"title": "Error:",
"value": truncate(test_case.failure, 150)
"value": truncate(test_case.failure ?? 'N/A', 150)
}
]
});
Expand Down

0 comments on commit 9e1fc65

Please sign in to comment.