2

I am using Cypress in my react app for integration test. I am facing coverage related problem, coverage report is showing blank. enter image description here

enter image description here

seems like code is not istrumented properly. can someone help me to figure what's wrong here?

Thanks!

  • 1
    React seems to be the easiest to instrument. I presume you've already seen [@cypress/code-coverage](https://github.com/cypress-io/code-coverage). For React (running React Scripts) you need [instrument-cra](https://github.com/cypress-io/instrument-cra) –  Apr 17 '21 at 09:46
  • @BarmyFotheringay-Phipps Yes I have already used @cypress/code-coverage. but my app is using React Scripts version 2 so facing problems with instrument-cra. – Garud Pragati Apr 18 '21 at 05:25
  • You are using React Scripts v2 but also react-hooks? Sounds like a potential conflict just within the React libraries. Why don't you update CRA? –  Apr 18 '21 at 21:52

1 Answers1

0

If you followed the cypress guide https://docs.cypress.io/guides/tooling/code-coverage and still not working, you may need to add the option --exclude-after-remap=false to your command, for example npx nyc report --reporter=text-summary --exclude-after-remap=false. You can see they mention that here https://bestofjs.org/projects/istanbul undeer the section 'Source-Map support for pre-instrumented codebases'

If you are using nyc with a project that pre-instruments its code, run nyc with the configuration option --exclude-after-remap set to false. Otherwise nyc's reports will exclude any files that source-maps remap to folders covered under exclude rules.

Miguel Salas
  • 692
  • 1
  • 6
  • 21