'Incorrect code coverage using nyc with Jest Based E2E Test Framework

I am trying to generate code coverage for the single e2e test case. Here is what I did to achieve this.

  1. Instrumented files related to e2e test case using nyc. Note here I used in place instrumentation
  2. Executed test cases.
  3. stored coverage report using window.__coverage__ into .nyc_output/coverage.json.
  4. generated report using nyc report --reporter=lcov --reporter=text command. created coverage folder

I can see that its showing branches , lines statements functions of instrumented code. Actually it should show statement , lines of original code.

Here is my nycrc file.

 {
  "extends": "nyc-config-tsx",
  "exclude": [
    "**/*.test.tsx",
    "**/*.mock.tsx",
    "**/*.test.ts",
    "**/*.mock.ts"
  ],
  "extension": [
    ".js",
    ".ts",
    ".jsx",
    ".tsx"
  ],
  "exclude-after-remap": false,
  "all": true,
  "cache": false,
  "source-map": true,
  "produce-source-map": true
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source