test_runner: source-mapped coverage marks an unexecuted return as covered
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 66/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript, node.js
研究方向
Start by running the reproduction with Node.js source maps and test coverage enabled, then compare its report with the same file after removing the source-map comment. Trace how the test runner maps executed JavaScript coverage back to the embedded TypeScript source; the issue gives no implementation file or test path, so first locate the coverage and source-map tests. Done means the uncovered return is reported as uncovered in both the text and lcov reports.
由索引模型根據 Issue 內容生成。
描述
Version
v26.12.1
Platform
Darwin arm64
Subsystem
test_runner coverage
Reproduction
Create these two files in an empty directory. No packages or module hooks are required. The inline source map contains its TypeScript source.
compiled.mjs
function choose(value) {
if (value) {
return "yes";
}
return "no";
}
export {
choose
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiZXhhbXBsZS50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiZXhwb3J0IGZ1bmN0aW9uIGNob29zZSh2YWx1ZTogYm9vbGVhbik6IHN0cmluZyB7XG4gIGlmICh2YWx1ZSkge1xuICAgIHJldHVybiBcInllc1wiO1xuICB9XG4gIHJldHVybiBcIm5vXCI7XG59XG4iXSwKICAibWFwcGluZ3MiOiAiQUFBTyxTQUFTLE9BQU8sT0FBd0I7QUFDN0MsTUFBSSxPQUFPO0FBQ1QsV0FBTztBQUFBLEVBQ1Q7QUFDQSxTQUFPO0FBQ1Q7IiwKICAibmFtZXMiOiBbXQp9Cg==
compiled.test.mjs
import assert from "node:assert/strict";
import test from "node:test";
import { choose } from "./compiled.mjs";
test("branch", () => assert.equal(choose(true), "yes"));
Run:
node --enable-source-maps --experimental-test-coverage --test compiled.test.mjs
The embedded original source is:
export function choose(value: boolean): string {
if (value) {
return "yes";
}
return "no";
}
Expected behavior
The test only calls choose(true). Original line 5 (return "no") should be uncovered. With the source-map comment removed, the JavaScript report correctly shows line 5 uncovered.
Actual behavior
The source-mapped report shows example.ts at 100% lines, 66.67% branches, and 100% functions, with no uncovered lines. The lcov reporter also emits DA:5,1. This overstates execution of a branch that the test never takes.
This reproduces with a single test process and a precompiled module. The example was generated using esbuild 0.28.2, but the reproduction above does not require esbuild. Related source-map coverage reports include #65946 and #67077; those describe off-thread hooks or merging multiple test processes, while this case needs neither.
- 主要語言
- JavaScript
- 星號
- 123k
- 分支
- 39.3k
- 平均合併
- 4 天 16 小時
- 30 天內合併 PR
- 227
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
nodejs/node 的其他 Issue
-
http2: content-encoding is incorrectly listed in kSingleValueHeaders可能已有人在做 @inoway46 於 1 天前認領。 未關閉confirmed-bug http2
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
util.parseEnv and --env-file keep a leading UTF-8 BOM in the first key可能已有人在做 @helmipradita 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already exist可能已有人在做 @Sepandard 於 37 天前認領。 未關閉doc
難度 1/5 1 小時以內 新手友好度 90/100
維護者通常 1 天內回覆
-
Stream.prototype.forEach will block in first promise in queue before read more chunk可能已有人在做 @mmustafasenoglu 於 38 天前認領。 未關閉doc
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
remotion-dev/remotion#12905 ·
維護者通常 1 天內回覆
-
enhancement websites
難度 2/5 1-3 小時 新手友好度 78/100
quarto-dev/quarto-cli#15255 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 72/100
mongoosejs/mquery#142 ·
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 65/100
維護者通常 1 天內回覆