bug: finally block in async function indicates incorrect missing block coverage
See original GitHub issueObserved Behavior
The following code:
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:
{
"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.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Finally in Promises & Try/Catch
If your finally block does not include a return statement, it has no effect on the return value. However, if you return a...
Read more >javascript - await in finally block of async function causes ...
When a Promise rejects, it must be handled before the current call stack clears, or there will be an unhandled rejection. You have:...
Read more >Practical Guide to Fp-ts P3: Task, Either, TaskEither
Some of the functions might never fail but are asynchronous out of ... are forced to handle these errors using a try-catch-finally block....
Read more >Error Messages
Test File Errors No tests found This message means that Cypress was unable to find ... Support file missing or invalid; Error Loading...
Read more >Code Inspections in JavaScript and TypeScript
Starting from ECMAScript 6, JavaScript blocks introduce new ... Missing await for an async function call ... Code is not covered by Flow....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bcoe Perfectly fair! Especially considering it’s going into maintenance mode in like, 2 months? So I’ll probably drop v12 before I even finish this wee babby of a tool, lol.
@xolott would you be able to provide a minimal breaking example, this would help in investigating the underlying cause.