Skip to content

Commit b6fb791

Browse files
cjihrigtargos
authored andcommitted
test_runner: support coverage of unnamed functions
This commit updates the code coverage logic to skip the first function in a file (which does not correspond to an actual function) instead of skipping all functions without a name. PR-URL: #47652 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 1f120a3 commit b6fb791

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/internal/test_runner/coverage.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class TestCoverage {
155155
});
156156

157157
for (let j = 0; j < functions.length; ++j) {
158-
const { functionName, isBlockCoverage, ranges } = functions[j];
158+
const { isBlockCoverage, ranges } = functions[j];
159159

160160
for (let k = 0; k < ranges.length; ++k) {
161161
const range = ranges[k];
@@ -172,7 +172,7 @@ class TestCoverage {
172172
}
173173
}
174174

175-
if (functionName.length > 0 && ranges.length > 0) {
175+
if (j > 0 && ranges.length > 0) {
176176
const range = ranges[0];
177177

178178
if (range.count !== 0 || range.ignoredLines === range.lines.length) {

test/fixtures/test-runner/coverage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if (false) {
2929
require('./invalid-tap.js');
3030
}
3131

32-
test('a test', function testHandler() {
32+
test('a test', () => {
3333
const uncalled = () => {};
3434

3535
function fnWithControlFlow(val) {

0 commit comments

Comments
 (0)