System information
$ uname -a
Linux thinkpad-avaq 4.19.75 #1-NixOS SMP Sat Sep 21 05:17:15 UTC 2019 x86_64 GNU/Linux
$ node -v
v12.11.1
(also tested on Node 12.5.0)
Description
In some cases (see below), c8 considers the newlines after a return statement to be "uncovered code".
Steps to reproduce
-
Install c8:
-
Write the following content to src/index.mjs:
const f = ({}) => {
const b = {};
return;
}
f ({});
-
Write the following content to test/index.mjs:
import '../src/index.mjs'
-
Run c8:
$ c8 node --experimental-modules test/index.mjs
(node:4857) ExperimentalWarning: The ESM module loader is experimental.
-----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
-----------|----------|----------|----------|----------|-------------------|
All files | 100 | 66.67 | 100 | 100 | |
index.mjs | 100 | 66.67 | 100 | 100 | 3 |
-----------|----------|----------|----------|----------|-------------------|
Expected result
I expect to see no uncovered lines.
Actual result
Line 3 ( return;) is considered "partially covered". If I add additional newlines after the return statement, they come up as fully uncovered lines. If I remove the statement prior to the return statement, the problem goes away. If I stop using destructuring in the function arguments, the problem also goes away.
Possible related issues
System information
(also tested on Node 12.5.0)
Description
In some cases (see below), c8 considers the newlines after a return statement to be "uncovered code".
Steps to reproduce
Install c8:
$ npm install c8Write the following content to
src/index.mjs:Write the following content to
test/index.mjs:Run c8:
Expected result
I expect to see no uncovered lines.
Actual result
Line
3(return;) is considered "partially covered". If I add additional newlines after the return statement, they come up as fully uncovered lines. If I remove the statement prior to the return statement, the problem goes away. If I stop using destructuring in the function arguments, the problem also goes away.Possible related issues