nyc icon indicating copy to clipboard operation
nyc copied to clipboard

Coverage configuration in .nycrc overrides package.json config.

Open MattRoss34 opened this issue 3 years ago • 2 comments

We have a default configuration specified in our .nycrc with the following:

{
    "extends": "@istanbuljs/nyc-config-typescript",
    "reporter": ["text", "html", "lcov"],
    "check-coverage": true,
    "lines": 0,
    "statements": 0,
    "functions": 0,
    "branches": 0
}

In each package, we override with package-specific settings via the nyc package.json stanza:

    "nyc": {
        "check-coverage": true,
        "branches": 100,
        "functions": 100,
        "lines": 100,
        "statements": 100
    },

With nyc 14.1.1 this worked fine, but after upgrading to nyc 15.1.0 this seems to be broken/switched. i.e. the .nycrc coverage config now takes precedence.

Link to bug demonstration repository

Expected Behavior

Coverage specs in the package.json "nyc" stanza should override coverage specs in the .nycrc file.

Observed Behavior

The coverage specs in the .nycrc file are taking precedence over the package.json config.

Troubleshooting steps

  • [ ] Base config in .nycrc is set to 0 for all coverages, package.json is set to 100 for all. Tests pass even though branch coverage is below 100.
  • [ ] Updated lines, statements, functions, and branches config to 100 in .nycrc and tests started failing.
  • [ ] Removed lines, statements, functions, and branches config from .nycrc and tests started failing due to package.json specs.

Environment Information

  System:
    OS: macOS 11.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 1.67 GB / 32.00 GB
  Binaries:
    Node: 12.22.1 - ~/.nvm/versions/node/v12.22.1/bin/node
    Yarn: 1.22.0 - ~/.nvm/versions/node/v12.22.1/bin/yarn
    npm: 6.14.12 - ~/.nvm/versions/node/v12.22.1/bin/npm

MattRoss34 avatar Apr 30 '21 17:04 MattRoss34

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar May 02 '22 17:05 stale[bot]

@MattRoss34 Did you find a solution to this? Experiencing exactly the same issue here right now.

stefandoorn avatar Aug 02 '22 12:08 stefandoorn