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

Can no longer get NYC to use absolute paths in lcov.info #1277

Closed
solymosi opened this issue Feb 3, 2020 · 5 comments
Closed

Can no longer get NYC to use absolute paths in lcov.info #1277

solymosi opened this issue Feb 3, 2020 · 5 comments

Comments

@solymosi
Copy link

solymosi commented Feb 3, 2020

File paths in lcov.info used to be absolute before 15.0.0. This has changed in the following PRs:

It looks like these PRs do such a good job of "adding support for relative path option" that they remove the possibility to use absolute paths altogether, since this.cwd is now always set as the projectRoot for the lcovonly module, which uses path.relative without the option to turn this feature off.

Is there some way to continue using absolute paths in lcov.info?
If this would need changes in the code, I'm happy to prepare a PR.

@coreyfarrell
Copy link
Member

nyc is complex with many options, my preference is to avoid unnecessary options as every option increases the learning curve. That is why I requested the removal of --relative=true from the linked PR's. I'm thinking that we could create a report alias such that nyc report -r lcovabsolute would produce output with absolute filenames. This would avoid creation of a new 'global' option / having to explain that it only applies to the lcov report.

CC @bcoe

@solymosi
Copy link
Author

solymosi commented Feb 5, 2020

@coreyfarrell – thanks for your feedback!

Speaking of global options, is there a way to pass in options to a particular reporter that is exposed somewhere – e.g. the nyc key in package.json or similar? That would be an obvious place to put this option.

Short of that I would also be fine with a separate lcovabsolute reporter as long as there is something that allows me to generate lcov.info files with absolute paths.

@solymosi
Copy link
Author

I ended up publishing my own plugin:
https://www.npmjs.com/package/nyc-report-lcov-absolute

It's not the most beautiful code I've ever written but it gets the job done.

@PaulRBerg
Copy link

PaulRBerg commented Sep 28, 2021

Is there still no solution besides @solymosi's custom plugin?

I'm running coverage in a monorepo, and I need to upload the reports to Coveralls. But because the reports use paths relative to each package, Coveralls cannot parse them. If they had been absolute, the upload would have worked.

@n10v
Copy link

n10v commented Jan 5, 2023

A comment from istanbuljs/istanbuljs#529 helped me to resolve the issue. I just added this line to the jest config of packages in my monorepo:

coverageReporters: [['lcov', { projectRoot: '../..' }]],

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

No branches or pull requests

4 participants