Skip to content

Incorrect coverage reported for ternaries in some situations #61

@Trott

Description

@Trott
  • Version: 11.9.0
  • Platform: Darwin Fhqwhgads.local 17.7.0 Darwin Kernel Version 17.7.0: Thu Dec 20 21:47:19 PST 2018; root:xnu-4570.71.22~1/RELEASE_X86_64 x86_64

In file foo.js:

'use strict';

function testIt (a, b) {
 const thing = a && b;
 console.log(thing);
 return a && b;
}

if (testIt(true, false))
  console.log('foo');

I run this:

c8 node foo.js

I get this:

false
----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |      100 |       60 |      100 |      100 |                   |
 foo.js   |      100 |       60 |      100 |      100 |              6,10 |
----------|----------|----------|----------|----------|-------------------|

I would have expected the coverage for line 4 (the assignment to thing) and line 6 (the return statement) to be the same. Instead, it is (correctly) reporting that 6 has some uncovered branches, but is omitting the same thing for line 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions