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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

LCOV reporter changed from Absolute file paths to Relative #9773

Closed
jcdesousa opened this issue Apr 5, 2020 · 13 comments
Closed

LCOV reporter changed from Absolute file paths to Relative #9773

jcdesousa opened this issue Apr 5, 2020 · 13 comments

Comments

@jcdesousa
Copy link

jcdesousa commented Apr 5, 2020

#9742 馃挜 Regression Report
After upgrading to the 25.2.7, we saw that our reported lcov.info file is not showing the absolute file paths anymore. This is causing a problem when reporting to sonarQube.

Before on 24.8.0:
SF:/Users/jose.sousa/git/project/webapp/common/App.js

Now on 25.2.7:
SF:common/App.js

Last working version

24.9.0

Stopped working in version:
25.1.0

To Reproduce

Steps to reproduce the behavior:

  • run jest with coverage and lcov reporter.
  • check lcov file generated and compare with the previous.
@jcdesousa jcdesousa changed the title Lcov reporter changed from Absolute file paths to Relative LCOV reporter changed from Absolute file paths to Relative Apr 5, 2020
@jcdesousa
Copy link
Author

It seems that for version 25.2.0, we need to configure the projectRoot to fix the relative path.

"coverageReporters": [
      ["lcov", {"projectRoot": "../"}],
      "text-summary"
    ]

@SimenB
Copy link
Member

SimenB commented Apr 5, 2020

Interesting... Did any Istanbul dependencies change during your upgrade? I didn't think any changes we made would affect this

@jcdesousa
Copy link
Author

Yes, I did further analises and it seems it stop working after 24.9.0. The version 25.1.0 does have some updates to istanbul dependencies.

@SimenB
Copy link
Member

SimenB commented Apr 5, 2020

Right. That's expected. Essentially istanbuljs/istanbuljs#529 and the linked PR to jest which allows you to set projectRoot is the "fix" on our side

@williamsousa
Copy link

@jcdesousa Thank's a lot. Works fine!

@randing89
Copy link
Contributor

randing89 commented Jul 20, 2020

After setting to

 ["lcov", {"projectRoot": "/"}]

The path is

SF:Users/jose.sousa/git/project/webapp/common/App.js

It is still not an absolute path

@Rey-Wang
Copy link

Rey-Wang commented Aug 28, 2020

@randing89 that's even a wrong path.
@jcdesousa Actually, we can solve this by using the sed command to correct the path in lcov.info, even though, you still need to take care of the path may different with the test-report.xml

@ramkrk
Copy link

ramkrk commented Jul 21, 2021

After upgrading to Jest 27.0.6, still facing the SF path issue in coverage reports.

without coverageReporters:

SF:app1/common/App.js

with coverageReporters ["lcov", {"projectRoot": "/"}] :

SF:Users//git/project/webapp/app1/common/App.js

with coverageReporters ["lcov", {"projectRoot": "__dirname"}] :

SF:..app1/common/App.js

Jest-config present in webapp folder

Am expecting the following:

Absolute SF Path: /Users//git/project/webapp/app1/common/App.js
Relative SF path: common/App.js

Right now using sed command to get it work.

Is there any workaround to fix it up in jest config level?

@dlarr
Copy link

dlarr commented Mar 25, 2022

Same problem, I am expecting absolute path. Anyone made any progress on this (except for the sed usage)

@jozefizso
Copy link

I have simple project where I use jest v29.4.3. I run npm test as jest --coverage without jest config. I get correct coverage report in console, the HTML report and XML files are correct.

When I run the jest --coverage locally on Windows or macOS system, the coverage/lcov.info contains correct path to app/index.js file:

TN:
SF:app\index.js
FN:19,(anonymous_0)
FN:81,(anonymous_1)

When I run the same project in GitHub Action in ubuntu-22.04 the path in lcov.info is incorrect. All the other files - HTML, XML reports, contain correct paths (eg. ):

TN:
SF:../../home/runner/work/generator-license/generator-license/app/index.js
FN:19,(anonymous_0)
FN:81,(anonymous_1)

From clover.xml:

<file name="index.js" path="/home/runner/work/generator-license/generator-license/app/index.js">

Copy link

github-actions bot commented Mar 3, 2024

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Mar 3, 2024
Copy link

github-actions bot commented Apr 2, 2024

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2024
Copy link

github-actions bot commented May 7, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants