Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2033691

Browse filesBrowse files
cjihrigMoLow
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 882c612 commit 2033691
Copy full SHA for 2033691

File tree

Expand file treeCollapse file tree

2 files changed

+3
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-3
lines changed
Open diff view settings
Collapse file

‎lib/internal/test_runner/coverage.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/coverage.js
+2-2Lines changed: 2 additions & 2 deletions
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) {
Collapse file

‎test/fixtures/test-runner/coverage.js‎

Copy file name to clipboardExpand all lines: test/fixtures/test-runner/coverage.js
+1-1Lines changed: 1 addition & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.