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

nyc_output folder not generated during automated build

Open RichieRunner opened this issue 3 years ago • 2 comments

Logs and screenshots Please provide debug logs by running Cypress from the terminal with DEBUG=code-coverage environment variable set, see the Debugging section of the README file.

Versions

  • What is this plugin's version? If this is NOT the latest released version can you try the latest version, please? "^3.9.11
  • 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? ^6.0.0
  • What is your operating system? Microsoft OS
  • What is the shell? CMD
  • What is the Node version? 16.3.0
  • What is the NPM version? 7.15.1
  • How do you instrument your application? Cypress does not instrument web application code, so you need to do it yourself.
    • With @cypress/instrument-cra and "start:coverage": "nyc --silent node index" (https://www.cypress.io/blog/2019/09/05/cypress-code-coverage-for-create-react-app-v3/)
  • 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? Yes
  • 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? Yes
  • Do you have any custom NYC settings in package.json (nyc object) or in other NYC config files: No
  • Do you run Cypress tests in a Docker container?: No

Describe the bug I'm running Cypress with the command DEBUG=code-coverage npx cypress run Cypress is able to generate .nyc_output locally, but not in automated build (Codebuild). Should the .nyc_output always be generated by Cypress on every cypress run?

image

I've recently discovered that my app built out to a server is NOT showing code coverage instrumentation in window.__coverage. Does this CRA instrumentation package work only for local environments? How do I instrument the app with npm run build?

RichieRunner avatar Nov 12 '21 01:11 RichieRunner

My research has led me to understand that I should be instrumenting code coverage through build, but I've now stumbled onto a new issue, which is this one

RichieRunner avatar Nov 12 '21 08:11 RichieRunner

The issue for me was during production build mode, I had to force my plugin to do instrumentation (vite-plugin-istanbul + forceBuildInstrumentation option).

ngokevin avatar Jun 02 '22 00:06 ngokevin