nyc icon indicating copy to clipboard operation
nyc copied to clipboard

ERROR: Coverage for lines (0%) does not meet global threshold (90%)

Open ghsouza89 opened this issue 1 year ago • 6 comments

Link to bug demonstration repository

sorry but i'm not able to share the repo because is a security policy from the company.

Expected Behavior

In my understanding i should see the coverage applied after follow the documentation and use nyc to instrument my application.

Observed Behavior

However i'm facing an error message and 0 coverage in the files that i want to be coverage:

ERROR: Coverage for lines (0%) does not meet global threshold (90%)

image

Troubleshooting steps

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

Environment Information

"nyc": "^15.1.0" doc reference: https://github.com/cypress-io/code-coverage#instrument-your-application

paste the output here

ghsouza89 avatar Apr 24 '23 14:04 ghsouza89

I have the same problem using v15.1.0.

Melchyore avatar Apr 29 '23 20:04 Melchyore

My repository is https://github.com/Beakerboy/Threejs-Geometries/tree/coverage

If I install nyc 15.1.0 with qunit 2.19.4, the unit tests run, but the coverage report fails to list any files. If I add --all, the coverage report does see all my files, but shows that no lines are covered.

nyc 15.0.1 gives me the error:

require() of ES Module /home/runner/work/Threejs-Geometries/Threejs-Geometries/src/PyramidGeometry.js not supported.
Instead change the require of PyramidGeometry.js in null to a dynamic import() which is available in all CommonJS modules.

My code does not have any require() statements. I saw a similar bug report that was attributed to and older version of babel. My GitHub repo is using @babel/[email protected]

In my case, it’s possible I’m just doing something completely wrong that the install and usage manual assumes I would know better than to do. However, my project is not very large nor complex; just three classes.

Beakerboy avatar May 05 '23 17:05 Beakerboy

For me, I was able to successfully replace nyc with bcoe/c8.

Beakerboy avatar May 08 '23 14:05 Beakerboy

@Beakerboy Hello, I met the same problem as you, I used nyc to test a project with Angular 11, only some branches coverage is 100, all lines coverage is 0. I also used c8, but all the coverage is 0, how did you achieve it?

kreamyu avatar Jul 05 '23 03:07 kreamyu

I just did a drop-in replacement. I called c8 quint instead of `nyc quint

my package.json includes this:

 "scripts": {
    "lint": "eslint .",
    "test": "c8 qunit"
  },
  "c8": {
    "all": true,
    "reporter": [
      "lcov",
      "text-summary"
    ]
  }

and my workflow includes:

    - name: Test
      run: npm test

https://github.com/Beakerboy/Threejs-Geometries/tree/main

Beakerboy avatar Jul 05 '23 16:07 Beakerboy

I had the same problem, I found a solution, you can see it here: https://stackoverflow.com/questions/76588140/error-coverage-for-lines-0-does-not-meet-global-threshold-90-cypress

VendenIX avatar Jul 18 '23 14:07 VendenIX