Closed KSchrage-SIT closed 2 months ago
It is a common issue, We can resolve full path of the file with option sourcePath
(issue https://github.com/cenfun/jest-monocart-coverage/issues/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
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
.
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;
}
}
Unfortunately that results in SF:../../../../src/App.vue
aswell.
That's weird. But I can't help you unless you provide the reproduction steps
Here's the repro-case. Thanks for your help, really appreciate it. Archiv.zip
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)
That did the trick. Thanks!
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 ofSF: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".