bcoe / bcoe/c8

bug: finally block in async function indicates incorrect missing block coverage

Open
#229 10 comments 4 reactions 0 assignees View on GitHub
bug p2 v8
Dominant language
JavaScript
Stars
2.1k
Forks
99
PR merge metrics
No merged PRs in 30d

Description

## Observed Behavior

The following code:

```js
async function abc() {
try {
return 'abc';
} finally {
console.log('in finally');
} // this is a covered line but uncovered branch
}

abc()
```

Ends up having the following coverage output:

```json
{
"functionName": "abc",
"ranges": [
{
"startOffset": 0,
"endOffset": 146,
"count": 1
},
{
"startOffset": 97,
"endOffset": 145,
"count": 0
}
],
"isBlockCoverage": true
}
}
```

This indicates that the following characters were tracked as an uncovered block:

```
// this is a covered line but uncovered branch\n
```

## Expected behavior

Coverage should be 100% in the above example.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.