question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
msolefontecommented, Dec 28, 2020

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.

2reactions
YoDaMacommented, Jan 30, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Istanbul code coverage : how to ignore such lines?
when performing code coverage , all my .catch() statements are uncovered, is there a way to specify /* istanbul ignore next */ somewhere...
Read more >
nyc | Yarn - Package Manager
Negated paths can restore paths that have been already been excluded in the exclude array. Multiple exclude globs can be specified on the...
Read more >
istanbuljs/nyc - Gitter
Question related to this, is there anyway I can get around test-exclude disallowing instrumentation of files outside of cwd ? Bazel runs targets...
Read more >
themusicgod1/nyc: the Istanbul command line ... - NotABug
Instrumenting your code. You can install nyc as a development dependency and add it to the test stanza in your package.json. npm i ......
Read more >
NYC Istanbul 'else path not taken' from import node_modules
There is a known bug when using Babel with Istanbul (NYC) that when you run coverage it displays coverage problems with else path...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found