nyc: bug: nyc with mocha not ignoring line using /* istanbul ignore next */

Link to bug demonstration repository

Our team is in the process of upgrading from Istanbul to NYC for our Typescript project:

Azure IoT SDK Node

I have created a branch within that repository that has the work I am doing to upgrade from Istanbul to NYC. You can see the branch as a PR here:

https://github.com/Azure/azure-iot-sdk-node/pull/682

One thing I observed while changing our tests is that code coverage on branches for our suite of tests under azure-iot-sdk-node/common/core dropped to 80%. That didn’t make any sense. After looking at what the lcov reporter output, I can see that it is perceiving a lack of coverage on the semicolons of the typescript file. This seems off. Here is a screenshot of the lcov report:

image

Expected Behavior

These semicolons are not labelled as branches that have not been tested.

Observed Behavior

Our branch coverage in the common/core set of files dropped from 96% to 80% with no change in tests / code.

Troubleshooting steps

  • still occurring when I put cache: false in my nyc config

Environment Information

  System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Xeon(R) W-2104 CPU @ 3.20GHz
    Memory: 12.34 GB / 31.73 GB
  Binaries:
    Node: 10.15.3 - C:\Program Files\nodejs\node.EXE
    npm: 6.13.5 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    source-map-support: ^0.5.16 => 0.5.16
    typescript: 2.9.2 => 2.9.2

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I forgot to update, but I solved it in my case. Hope I can help someone.

The problem was that I had a flag enabled in TSC to remove comments from the code, so the JS version (the one that is actually executed by NYC) did not read any “/* istambul */” flag. Easy to solve problem once I found it.

Upon deeper inspection I see that NYC is having trouble dealing with the following transpiled line:

        /* istanbul ignore next */
        _super.call(this, message) || this;

istanbul should ignore this line but it is not, and instead getting upset with the branch for this which in it’s mind is not tested.