-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Vitest Coverage v8 & Istanbul Providers Broken #27003
Comments
Looks like something is different in the inspector. On Deno I get these coverage lines: [
// ...
{
scriptId: '406',
url: '/Users/marvinh/dev/test/deno-vitest-cov2/src/foo.test.js',
functions: [ [Object], [Object], [Object] ]
},
{
scriptId: '408',
url: '/Users/marvinh/dev/test/deno-vitest-cov2/src/foo.ts',
functions: [ [Object], [Object], [Object], [Object] ]
}
] Whereas in Node I get this: [
// ...
{
scriptId: '265',
url: 'file:///Users/marvinh/dev/test/deno-vitest-cov2/src/foo.test.js',
functions: [ [Object], [Object], [Object] ]
},
{
scriptId: '267',
url: 'file:///Users/marvinh/dev/test/deno-vitest-cov2/src/foo.ts',
functions: [ [Object], [Object], [Object], [Object] ]
}
] This is problematic because session.post("Profiler.takePreciseCoverage", async (error, coverage) => {
//...
const result = coverage.result.filter(filterResult);
resolve({ result });
});
function filterResult(coverage) {
if (!coverage.url.startsWith("file://")) {
return false;
}
if (coverage.url.includes("/node_modules/")) {
return false;
}
return true;
} I wasn't able to isolate it further as just doing the inspector stuff leads to the correct script urls being printed. Not sure why they are stripped with Steps to reproduce
|
Blocked on denoland/deno#27003.
@marvinhagemeister |
Blocked on denoland/deno#27003.
Blocked on denoland/deno#27003.
Blocked on denoland/deno#27003.
While looking into issue on Vitest side (vitest-dev/vitest#7660), noticed that this minimal reproduction works on Node but not on Deno. Should import inspector from "node:inspector";
function firstMethod() {}
const session = new inspector.Session();
session.connect();
session.post("Profiler.enable");
session.post("Profiler.startPreciseCoverage", { callCount: true, detailed: true });
firstMethod();
const coverage = await new Promise((resolve, reject) => {
session.post("Profiler.takePreciseCoverage", async (error, coverage) => {
if (error) return reject(error);
resolve(coverage.result.filter((entry) => !entry.url.startsWith("node:")));
});
});
console.log(JSON.stringify(coverage, null, 2)); $ deno -v; deno --allow-sys ./coverage.mjs
deno 2.2.3
[]
$ node -v; node ./coverage.mjs
v22.14.0
[
{
"scriptId": "94",
"url": "file:///Users/x/coverage.mjs",
"functions": [
{
"functionName": "firstMethod",
"ranges": [
{
"startOffset": 41,
"endOffset": 66,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "coverage",
"ranges": [
{
"startOffset": 297,
"endOffset": 520,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "",
"ranges": [
{
"startOffset": 367,
"endOffset": 516,
"count": 0
}
],
"isBlockCoverage": false
}
]
}
] |
I don't know if vitest/istanbul coverage works at this point or not, but I can't reproduce the causes claimed above. Deno is showing import inspector from "node:inspector";
function firstMethod() {}
const session = new inspector.Session();
session.connect();
session.post("Profiler.enable", () => {
session.post("Profiler.startPreciseCoverage", { callCount: true, detailed: true }, () => {
firstMethod();
session.post("Profiler.takePreciseCoverage", (error, result) => {
const coverage = result.result.filter((entry) => !entry.url.startsWith("node:") && !entry.url.startsWith('ext:'));
console.log(JSON.stringify(coverage, null, 2));
});
});
}); |
Relates to #23882.
Version: Deno 2.1.1
The v8 provider returns 0 for everything.



The istanbul provider is just wrong:
I think instanbul is mostly just mapping the line #s wrong, but it generally looks accurate-ish.
The text was updated successfully, but these errors were encountered: