code-coverage icon indicating copy to clipboard operation
code-coverage copied to clipboard

The index.html show unknown% and a blank report even after out.json has data.

Open maddy619 opened this issue 5 years ago • 6 comments

image

Out.json image

Versions

 "@cypress/code-coverage": "3.2.2",
    "cypress": "3.6.1",
    "istanbul-instrumenter-loader": "^3.0.1",
    "ngx-build-plus": "^7.8.3",
    "nyc": 15.0.1 

nyc comes with cypress code-coverage plugin

  • Node version - 12.14.1

  • NPM version - 6.13.4

  • Angular version - 6.2.9

  • How do you instrument your application- using istanbul-instrumenter-loader and following bahmutov`s project. https://github.com/bahmutov/cypress-angular-coverage-example

  • window.__coverage__ object was successfully create, cant paste here..!

  • .nyc_output

{
  "D:\\Project\\projects\\feature-x\\src\\app\\app.module.ts": {
    "path": "D:\\Project\\projects\\feature-x\\src\\app\\app.module.ts",
    "statementMap": {
      "0": {
        "start": {
          "line": 2,
          "column": 17
        },
        "end": {
          "line": 7,
          "column": 1
        }
      },
      "1": {
        "start": {
          "line": 3,
          "column": 12
        },
        "end": {
          "line": 3,
          "column": 28
        }
      },
      "2": {
        "start": {
          "line": 3,
          "column": 34
        },
        "end": {
          "line": 3,
          "column": 125
        }
      },
      "3": {
        "start": {
          "line": 4,
          "column": 4
        },
        "end": {
          "line": 5,
          "column": 150
        }
      },
  • Do you have any custom NYC settings in package.json -No
  • Do you run Cypress tests in a Docker container? - No on local

I am working on angular app, using typescript and ts-loader. I am able to successfully instrument code. The folder structure is something like this. Code folder: Project/projects/feature-x/src/app Cypress folder: Project/projects/feature-cypress/cypress.

Coverage.webpack.js is parallel to cypress folder.

maddy619 avatar May 04 '20 13:05 maddy619

Can you include DEBUG logs please https://github.com/cypress-io/code-coverage#debugging or give a link to the repo?

bahmutov avatar May 05 '20 18:05 bahmutov

I'm experiencing a similar problem. The file nyc_output/out.json is populated with data and I use @cypress/instrument-cra which neatly makes __coverage__ available. Reports generated by nyc are empty. However, the report generated by Cypress in coverage/lcov-report/index.html renders as it's supposed to.

johanbook avatar Sep 03 '20 14:09 johanbook

What is the situation with this, I get same behaviour as described above, html report is generated, also nyc out.json, but nyc command line tool bundled within generates always 'Unknown' for code coverage?

Versions: node v12.18.4 +

"@cypress/code-coverage": "3.9.5",
"cypress": "7.3.0",

ari-luokkala avatar May 18 '21 10:05 ari-luokkala