From c01b4161b98f5681c3a23cab2d5af7b435f3286f Mon Sep 17 00:00:00 2001 From: Matthew Noorenberghe Date: Wed, 10 Jul 2024 17:18:50 -0400 Subject: [PATCH] Slack: Handle a failure without a failure message The message attribute of `` is optional and some tools print the message in the textContent. We shouldn't output `undefined` if it's not present. See https://github.com/test-results-reporter/parser/issues/73 for the root issue --- src/targets/slack.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/targets/slack.js b/src/targets/slack.js index c59c85f..a6ea3b4 100644 --- a/src/targets/slack.js +++ b/src/targets/slack.js @@ -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 {