Skip to content

Generated HTML has errors for some files (0% coverage even though showing non-zero items) #279

@jhpedemonte

Description

@jhpedemonte

Logs and screenshots

Screen Shot 2020-07-21 at 4 22 37 PM

Screen Shot 2020-07-21 at 4 22 53 PM

Versions

  • What is this plugin's version? If this is NOT the latest released version can you try the latest version, please?

"@cypress/code-coverage": "^3.8.1"

  • If the plugin worked before in version X, but stopped after upgrading to version Y, please try the released versions between X and Y to see where the breaking change was.
  • What is Cypress version?

"cypress": "4.10.0"

  • What is your operating system?

RHEL

  • What is the shell?

sh

  • What is the Node version?

12.14.1 (Using Docker image cypress-included:4.10.0

  • What is the NPM version?

🤷

Use craco to customize create-react-app's webpack config to add the babel-plugin-instanbul plugin. Similar to what is done by instrument-cra but building instead of running in dev mode (similar to cypress-io/instrument-cra#135 (comment)).

  • When running tests, if you open the web application in regular browser, and open DevTools, do you see window.__coverage__ object? Can you paste a screenshot?
  • Is there .nyc_output folder? Is there .nyc_output/out.json file. Is it empty? Can you paste at least part of it so we can see the keys and file paths?
  • Do you have any custom NYC settings in package.json (nyc object) or in other NYC config files
  "nyc": {
    "extends": "@istanbuljs/nyc-config-typescript",
    "all": true,
    "exclude": [
      "cypress/**",
      "**/__fixtures__/**",
      "**/__mocks__/**",
      "**/__tests__/**"
    ],
    "report-dir": "./coverage-cypress",
    "temp-dir": "./coverage-cypress/.nyc_output",
    "reporter": [
      "text-summary",
      "json",
      "html"
    ]
  }
  • Do you run Cypress tests in a Docker container?

Yes, custom image based on cypress-included:4.10.0.

Describe the bug

After building an instrumented build and running Cypress tests, the generated HTML code coverage report shows some files with 0% coverage but actually having some non-zero covered code (see screenshots above).

When viewing one such file in the HTML report, it will show an error instead of file contents:

Cannot read property 'locations' of undefined
TypeError: Cannot read property 'locations' of undefined
    at /Users/pedemonte/projects/watson-discovery/discovery-tooling/node_modules/istanbul-reports/lib/html/annotator.js:127:50
    at Array.forEach ()
    at annotateBranches (/Users/pedemonte/projects/watson-discovery/discovery-tooling/node_modules/istanbul-reports/lib/html/annotator.js:125:33)
    at annotateSourceCode (/Users/pedemonte/projects/watson-discovery/discovery-tooling/node_modules/istanbul-reports/lib/html/annotator.js:233:9)
    at HtmlReport.onDetail (/Users/pedemonte/projects/watson-discovery/discovery-tooling/node_modules/istanbul-reports/lib/html/index.js:409:33)
    at Visitor.value (/Users/pedemonte/projects/watson-discovery/discovery-tooling/node_modules/istanbul-lib-report/lib/tree.js:38:38)
    at ReportNode.visit (/Users/pedemonte/projects/watson-discovery/discovery-tooling/node_modules/istanbul-lib-report/lib/tree.js:88:21)
    at /Users/pedemonte/projects/watson-discovery/discovery-tooling/node_modules/istanbul-lib-report/lib/tree.js:92:19
    at Array.forEach ()
    at ReportNode.visit (/Users/pedemonte/projects/watson-discovery/discovery-tooling/node_modules/istanbul-lib-report/lib/tree.js:91:28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions