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
Coverage paths are no longer fully resolved #529
Comments
My monorepo coverage broke due to relative paths too. If it helps I solved the issue by providing
|
Paths should be relative IMHO. I'm currently user of So I think relative paths are the better default. |
@sebastianhaeni what @MartinNuc describes is the fix I put in jest to support reporter configuration. |
For me it seems like the lcov tracefile format was defined by the Linux Test Project (http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php), if that is not the original source, please correct me. There it is defined, that source files should be referenced by absolute paths:
Even if relative paths are more flexible, IMHO for compatibility reasons the default format should therefore be absolute paths. Other tools might depend on this, see for example Webstorm/WEB-46615, sonarcloud.io karma-runner/karma-coverage#415. Note that in karma-coverage, unfortunately the fileformat change (absolute -> relative paths) was introduced in a patch version (2.0.2), therefore possibly in violation with semantic versioning, as it is not backwards compatible. In istanbuljs/nyc#1277 it was suggested that instead of adding more options
should be introduced (which another user created an npm package for). However, from my point of view it would make more sense to use the absolute format by default, if the original format definition states that absolute paths should be used, adding an Also #532 could possibly at least allow both relative and absolute paths to be used, without creating an additional reporter. Furthermore it seems that absolute paths are currently not supported by Alternatively all depending projects would have to detect, whether relative paths are used and have to be made compatible. Either way I think there are / will be some breaking changes for developers. |
I totally agree that if a standard format exists, it should be followed. This is causing issues for the Code Climate coverage tool, too. |
Since #492, we have issues when reporting our coverage to tools like Sonaqube on our monorepo projects.
This PR effectively makes all the coverage reports file paths relative to the
projectRoot
. In our case, using jest in a mono repo context, this prevents us from properly analyzing the code through sonarqube. (sonarqube analysis occurs at the root of the mono repo and all the relative paths cannot be resolved.)Temporarily, we use a custom lcov reporter in jest, that sets the appropriate
projectRoot
relative to the mono repo root, but it's not ideal, as this need to be done for every module of the mono-repo.Currently, jest does not support configuring / passing additional options to the coverage reporters.
I can see multiple ways out:
projectRoot
we could default to full paths..istanbulrc
or something similarThe text was updated successfully, but these errors were encountered: