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

🐛 Cypress: JUnit reporter is incorrectly reported as unlisted dependency #798

Open
6 tasks done
duncan-thacker opened this issue Oct 3, 2024 · 4 comments · May be fixed by #803
Open
6 tasks done

🐛 Cypress: JUnit reporter is incorrectly reported as unlisted dependency #798

duncan-thacker opened this issue Oct 3, 2024 · 4 comments · May be fixed by #803
Labels
bug Something isn't working

Comments

@duncan-thacker
Copy link
Contributor

Prerequisites

Reproduction url

https://codesandbox.io/p/sandbox/musing-gagarin-d4vvr9

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

In a Cypress config, setting "reporter": "junit" causes knip to incorrectly report junit as an unlisted dependency. Cypress bundles a junit reporter (see https://docs.cypress.io/guides/tooling/reporters) and does not depend on the junit package (I verified this by installing Cypress and then doing npm ls junit). The Junit functionality appears to be somewhere inside the Cypress package.

Here is the report knip produces:

Unlisted dependencies (1)
junit  cypress.config.ts

Looking at the plugin code for cypress, it appears to assume all listed reporters are package names, even though this isn't correct (not sure I've read this correctly!)

https://github.com/webpro-nl/knip/blob/main/packages/knip/src/plugins/cypress/helpers.ts

Workarounds

I can install the junit package but that seems wasteful. I could also switch to another Junit reporter (e.g. mocha-junit-reporter) but that also seems pointless.

@duncan-thacker duncan-thacker added the bug Something isn't working label Oct 3, 2024
@webpro
Copy link
Collaborator

webpro commented Oct 3, 2024

Thanks for the report, @duncan-thacker!

Looking at the plugin code for cypress, it appears to assume all listed reporters are package names, even though this isn't correct (not sure I've read this correctly!)

Yeah that's where the "magic" happens. Any chance you'd be up for a pull request?

@duncan-thacker
Copy link
Contributor Author

Potentially - I would probably need some help though as

  1. I'm not 100% confident how the code works
  2. It's not clear from the Cypress docs whether the reporter field might need resolving in some cases. I'll need to go digging through the source to figure it out. The changelogs seem to mention "mocha-junit-reporter" a lot, but it doesn't seem to be a cypress dependency, so I'm a bit confused...

If I get time I'll give this a go.

@webpro
Copy link
Collaborator

webpro commented Oct 3, 2024

Looks like we can ignore the largest part of this file. resolveEntry tries to resolve to package or (local) entry file (which it already does). Maybe we could just filter junit out of the reporters? And mocha-junit-reporter is an external package so wouldn't need special treatment I think.

@duncan-thacker
Copy link
Contributor Author

Yeah, according to this page https://docs.cypress.io/guides/tooling/reporters we can also filter out teamcity

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

Successfully merging a pull request may close this issue.

2 participants