Skip to content
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

'Error: undefined' appears on failure-details Slack message #73

Open
mnoorenberghe opened this issue Jul 9, 2024 · 8 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@mnoorenberghe
Copy link

SLACK_MESSAGE_FORMAT=failure-details npx testbeats publish -c testbeats.config.js
Screenshot 2024-07-09 at 3 11 14 PM

Example junit.xml from jest-junit:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="E2E Test" tests="38" failures="12" errors="0" time="334.312">
  <testsuite name="site-info" errors="0" failures="12" skipped="0" timestamp="2024-07-09T14:03:34" time="332.454" tests="38">
    <testcase classname="foo should be correct for: bar" name="foo should be correct for: bar" time="20.74" file="test.ts">
      <failure>Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

@@ -1,7 +1,7 @@
  Object {
-   &quot;Address&quot;: &quot;7, Stone Hill&quot;,
+   &quot;Address&quot;: &quot;&quot;,
    &quot;First Name&quot;: &quot;Bob&quot;,
    &quot;Last Name&quot;: &quot;Tree&quot;,
    &quot;Status&quot;: &quot;&quot;,
    at /test.ts:113:33
    at processTicksAndRejections (node:internal/process/task_queues:96:5)</failure>
    </testcase>
  </testsuite>
</testsuites>
@ASaiAnudeep ASaiAnudeep added the bug Something isn't working label Jul 10, 2024
@ASaiAnudeep
Copy link
Member

ASaiAnudeep commented Jul 10, 2024

Seems to be a bug from jest-junit implementation.

failure element should have a message property to include the error.

Reference: https://github.com/junit-team/junit5/blob/main/platform-tests/src/test/resources/jenkins-junit.xsd#L31-L36

@ASaiAnudeep ASaiAnudeep transferred this issue from test-results-reporter/testbeats Jul 10, 2024
@ASaiAnudeep ASaiAnudeep self-assigned this Jul 10, 2024
@mnoorenberghe
Copy link
Author

failure element should have a message property to include the error.

Does use="optional"mean it's optional? If so, then it doesn't mean it should.

@ASaiAnudeep
Copy link
Member

The message property or failure element may be optional. According to the schema, error text should belong to the message property and not elsewhere.

I understand that many test frameworks do not consistently adhere to a specific pattern. It would be beneficial to address this within the jest-unit reporter. We are also open to making adjustments if this can benefit the community overall.

@leelaprasadv
Copy link
Contributor

@mnoorenberghe we might have a workaround here.

According to jest-junit plugin code, adding --noStackTraceto your jest test should create the junit XML with nested message attributes (if everything else checks out) for failure tests.

https://github.com/jest-community/jest-junit/blob/master/utils/buildJsonResults.js#L86

Note: this would mean the entire stack trace will likely be removed and may not be reported to slack.

You could try adding a link to the test run/build in the notification for users to view the error message printed on the console instead.

@mnoorenberghe
Copy link
Author

The message property or failure element may be optional. According to the schema, error text should belong to the message property and not elsewhere.

I would be fine with it just omitting the Error: undefined portion of the Slack message if that is undefined (since it's optional according to the xsd)

According to jest-junit plugin code, adding --noStackTraceto your jest test should create the junit XML with nested message attributes (if everything else checks out) for failure tests.

Thanks, I'll give that a try now.

@mnoorenberghe
Copy link
Author

According to jest-junit plugin code, adding --noStackTraceto your jest test should create the junit XML with nested message attributes (if everything else checks out) for failure tests.

Thanks, I'll give that a try now.

The code never sets the message attribute AFAICT, regardless of --noStackTrace.

mnoorenberghe added a commit to mnoorenberghe/testbeats that referenced this issue Jul 10, 2024
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
mnoorenberghe added a commit to mnoorenberghe/testbeats that referenced this issue Jul 11, 2024
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
ASaiAnudeep pushed a commit to test-results-reporter/testbeats that referenced this issue Jul 11, 2024
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
@mnoorenberghe
Copy link
Author

Does this project have any interest in retrieving the error message from the contents of the <failure> like how jest-junit produces it?

@ASaiAnudeep
Copy link
Member

I see a growth in number of users using jest-junit reporter. We can fix this issue in the following ways..

  • Make changes to the actual package to follow the jUnit standards.
  • Fork it. Fix it. And release it under a new name.
  • Or use patch-package to fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants