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

Bug with v8 Paths, but not sure what is the root cause #5

Closed
Aghassi opened this issue Jul 11, 2024 · 3 comments
Closed

Bug with v8 Paths, but not sure what is the root cause #5

Aghassi opened this issue Jul 11, 2024 · 3 comments

Comments

@Aghassi
Copy link
Contributor

Aghassi commented Jul 11, 2024

I followed the example provided in the README, but the issue I'm seeing with my system is that the v8 data strips out the sourcePath from the file. This does not happen if the jest config does not have coverageProvider: 'v8'. The thing is, I'm not sure why this is happening. I'm opening this issue more to discuss. I have not made a way to publicly reproduce because this is on our internal monorepo with Bazel.

Basically, the lcov file generate is missing path/to/file.ts with that option on. It just returns file.ts.

I have some theories, but nothing concrete. Any ideas?

@cenfun
Copy link
Owner

cenfun commented Jul 12, 2024

This path issue could be a sourcemap issue. The sourcemap of the file didn't provide the full path of the file.

{"version":3,"sources":["file.js"],"sourcesContent":[ ...

It is supposed to be:

{"version":3,"sources":["path/to/file.js"],"sourcesContent":[ ...

Please try to normalize the sourcePath with option sourcePath.
Possible solutions:

const path = require("path")

// MCR coverage options
{
  sourcePath: (filePath, info)=> {
    if (!filePath.includes('/') && info.distFile) {
      return `${path.dirname(info.distFile)}/${filePath}`;
    }
    return filePath;
  },
  
}

@Aghassi
Copy link
Contributor Author

Aghassi commented Jul 12, 2024

Thanks I believe that did it! That's definitely worth documenting in the README. Should it go in this repo or the monocart main one?

cenfun added a commit that referenced this issue Jul 12, 2024
@cenfun
Copy link
Owner

cenfun commented Jul 12, 2024

Thank you for the reminder, I have updated the document for both jest-monocart-coverage and monocart-coverage-reports repo.

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

2 participants