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

Add JUnit reporter #586

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Add JUnit reporter #586

wants to merge 10 commits into from

Conversation

mrdannael
Copy link

Closes #568

PR aims to implement a reporter for generating JUnit xml. Without --reporter-options it will output the results to the console. By providing path value, the reporter will try to put the output into the file.

Added small "fast-xml-parser" package to the knip package.

Also updated the docs with info about Junit reporter.

</testsuite>
<testsuite name="Unlisted dependencies" tests="2" failures="2">
<testcase tests="1" failures="1" name="Unlisted dependencies" classname="src/index.ts">
<failure message="Unlisted dependencies - unresolved" type="Unlisted dependencies">Unlisted dependencies: "unresolved" inside src/index.ts</failure>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know anything about this format, but will each issue be in its own node, or should it be? This example gives me the impression that all unlisted dependencies will end up in this single node? Or will each one have the "Unlisted dependencies: " prefix?

Maybe you could show an example of how it looks like in the CI environment (eg. Bitbucket)?

Copy link
Author

@mrdannael mrdannael Apr 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. I've already used this junit reporter during development and tested it with configured Bitbucket. I'll gather some real-life data and post it here for further discussion.

@webpro
Copy link
Collaborator

webpro commented Jun 15, 2024

Is there still interest in wrapping up this pull request?

@mrdannael
Copy link
Author

mrdannael commented Jun 15, 2024

Yeah, absolutely.
Thanks for the reminder.

That's how bitbucket diplays the test results file.
Screenshot from 2024-06-15 16-23-00

But now i see that there are some differences between bitbucket output and the test case provided within PR.
They don't match. I'll try to re-generate the output again.

@mrdannael
Copy link
Author

This is the actual output from junit reporter on Bitbucket pipelines run on the live project:

Screenshot from 2024-06-16 19-41-14

And this is part of the output xml file that was reported after running knip (in txt because Github won't allow to attach xml file). I've cut some sensitive data from the file (that's why issues count don't match with the image from BB).

test-knip-report.txt

@webpro webpro force-pushed the main branch 2 times, most recently from d692d08 to 7aa2f6d Compare June 19, 2024 10:56
Copy link

netlify bot commented Jun 19, 2024

👷 Deploy request for knip pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 51ef8f2

@webpro
Copy link
Collaborator

webpro commented Jun 29, 2024

I feel like we could improve the output a bit.

For instance, I see this in one section:

json.Unused devDependencies package ⋁

1 Unused devDependencies - postcss-scss
2
3 Unused devDependencies: "postcss-scss" inside package.json
4

Maybe all unused devDependencies of a file can go into a single foldout, without the duplication? Eg:

Unused devDependencies in package.json ⋁

1 postcss-scss
2 postcss-syntax

Doesn't need to be perfect, but I wonder how close we can get to something more like this?

@mrdannael
Copy link
Author

mrdannael commented Jul 2, 2024

I need to test if BitBucket will accept something like that

<testsuite name="Unused dependencies" tests="1" failures="4">
    <testcase tests="1" failures="4" name="Unused dependencies" classname="package.json">
      <failure message="Unused dependencies - @types/google.accounts" type="Unused dependencies">Unused dependencies: "@types/google.accounts" inside package.json</failure>
      <failure message="Unused dependencies - fast-xml-parser" type="Unused dependencies">Unused dependencies: "fast-xml-parser" inside package.json</failure>
      <failure message="Unused dependencies - type-fest" type="Unused dependencies">Unused dependencies: "type-fest" inside package.json</failure>
      <failure message="Unused dependencies - web-vitals" type="Unused dependencies">Unused dependencies: "web-vitals" inside package.json</failure>
    </testcase>
  </testsuite>

or other similar output. If yes, then more compact output without duplications should be possible.
I'll try different formats.

@webpro webpro force-pushed the main branch 2 times, most recently from 300ed3d to fe1168b Compare July 12, 2024 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Junit reporter
2 participants