Skip to content

Commit 2033691

Browse 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

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎lib/internal/test_runner/coverage.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class TestCoverage {
155155
});
156156

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

160160
for(letk=0;k<ranges.length;++k){
161161
constrange=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
constrange=ranges[0];
177177

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

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

Lines 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',functiontestHandler(){
32+
test('a test',()=>{
3333
constuncalled=()=>{};
3434

3535
functionfnWithControlFlow(val){

0 commit comments

Comments
 (0)