-
Notifications
You must be signed in to change notification settings - Fork 110
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
Feature Request: Add line
attribute to <testcase>
element
#228
Comments
Hey thanks for submitting an issue! Couple of issues with implementing this, unfortunately. jest-junit follows the jenkins junit xsd and this field is not part of that. Hard for me to say what impact it would have adding a non-standard field to everyones junit as different CI and reporting systems vary but since inception jest-junit has followed that spec. Details here https://github.com/jest-community/jest-junit/blob/master/__tests__/lib/junit.xsd#L42 The other issue is that jest does not pass reporters line numbers for tests so I don't have the ability to even add this field simply using the information that jest passes to reporters. More details here: https://github.com/facebook/jest/blob/main/packages/jest-reporters/src/types.ts |
Thanks for the context! Completely understood about the spec, though I'm curious if you'd consider making the attribute optional and default to off? As for whether Jest passes the line number, I went digging and discovered that newer versions of Jest have a GHA reporter. I'll give that a try today to see if it can meet my needs. They use the frame information to extract the line number in that reporter - see here: https://github.com/facebook/jest/blob/3b0a975269a3b712d0235f67fbd072dd9cb867b2/packages/jest-reporters/src/GitHubActionsReporter.ts#L60 |
Ah that is interesting. Seems like it derives the line number from a stack trace so I suppose only failing test cases would contain a line number. If you submit a PR making it an optional attribute I am happy to review! |
@palmerj3 Would you mind re-opening this issue? I've created an internal ticket to open a PR for this feature and would like to use this issue to help track |
@sayhiben Any update on that PR? |
Firstly, thanks for the library; it's super useful.
My team uses GitHub Actions as our CI orchestration layer. We use the jUnit XML format for consistent reporting across different parts of our stack, which allows us to use a common reporting tool that annotates our builds and PRs: https://github.com/mikepenz/action-junit-report
This GitHub Marketplace Action supports the
line="1234"
attribute on<testcase>
elements in junit.xml files and uses it to show failures in context of the PR:Currently, jest-junit does not include the necessary attribute in the junit xml output, so the GHA action always annotates the failures at line 1.
Please consider the addition of the
line="1234"
attribute on<testcase>
elements, both for success and failures. Our Python test runner outputs the line number that refers to the first line of each test, regardless of outcome.The text was updated successfully, but these errors were encountered: