How to include monorepo packages in Cypress code coverage

I have multi packages in monorepo.

/pkg1
/pkg2
/pkg3
     - react-app
     - cypress
     - src
     - package.json

I am using @cypress/instrument-cra to collect coverage and it works only to cover the code inside react-app.

I need to go further because react-app is actually just a playground while the src has to be covered along with other packages that are used inside the react-app. I am importing packages as following:

import pkg1 from @myProject/pkg1

How can I use code coverage for pkg1?

I tried to config nyc but it didn’t work

"nyc": {
  "all": true,
  "include": [
    "node_modules"
  ],
  "excludeNodeModules": false
}

Thanks!

15 thoughts on “How to include monorepo packages in Cypress code coverage”

Leave a Comment