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

Complete sourcepath in the SF line of lcov.info is missing #1

Closed
KSchrage-SIT opened this issue Aug 14, 2024 · 8 comments
Closed

Complete sourcepath in the SF line of lcov.info is missing #1

KSchrage-SIT opened this issue Aug 14, 2024 · 8 comments

Comments

@KSchrage-SIT
Copy link

I followed the instructions and got coverage working as described. I noticed however, that the lcov.info is missing the full sourcepath of the specifiv files. It only lists the file name.

We get the following SF:App.vue instead of SF:src/App.vue, for example. The ladder is generated from vitest/unit-tests.

Is there any configuration setting I can use here? It seems, that the information is somehow "there", since the generated html-report lists something like "http://localhost-3200/src/App.vue: App.vue".

@cenfun
Copy link
Owner

cenfun commented Aug 14, 2024

It is a common issue, We can resolve full path of the file with option sourcePath (issue cenfun/jest-monocart-coverage#5)

const path = require("path")

// MCR coverage options
{

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

See sourcePath

@KSchrage-SIT
Copy link
Author

Jeah, that looks better now. However I now have SF:localhost-3200/src/App.vue instead of SF:/src/App.vue. Stripping out the localhost-3200 within the sourcePath-lambda, results in SF:../../../../src/App.vue. Do I have to combine this with baseDir or something like that? I double checked the result of the lambda and it returns with /src/App.vue.

@cenfun
Copy link
Owner

cenfun commented Aug 14, 2024

Try following

const path = require("path")

// MCR coverage options
{

    sourcePath: (filePath, info)=> {

        const str = 'localhost-3200';
        if (filePath.startsWith(str)) {
            return filePath.slice(str.length);
        }

        if (!filePath.includes('/') && info.distFile) {
            return `${path.dirname(info.distFile)}/${filePath}`;
        }
        return filePath;
    }
  
}

@KSchrage-SIT
Copy link
Author

Unfortunately that results in SF:../../../../src/App.vue aswell.

@cenfun
Copy link
Owner

cenfun commented Aug 14, 2024

That's weird. But I can't help you unless you provide the reproduction steps

@KSchrage-SIT
Copy link
Author

Here's the repro-case. Thanks for your help, really appreciate it.
Archiv.zip

@cenfun
Copy link
Owner

cenfun commented Aug 15, 2024

It seems that we need to remove /

// previous
// const str = "localhost-3200";
// please change to

const str = "localhost-3200/";
TN:
SF:src\App.vue
FN:1,(anonymous_0)

@KSchrage-SIT
Copy link
Author

That did the trick. Thanks!

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