Asking
Asking

Reputation: 4172

Get code coverage only for a folder in Cypress

I am using Cypress and Nyc configurations. My folder structure looks like this:

|/project
| /coverage/
   /lcov-report
    /index.html
 
|/cypress
| /main
   /car
    /car.spec.tsx
    /color.spec.tsx
     ...
| /integration

I need a solution to get inside the index.html only the tests coverage from main folder. So as a result in index.html i need to see only the coverage for the tests that was written there.
I noticed that NYC docs. have some configurations https://github.com/istanbuljs/nyc#common-configuration-options . But there i can specifiy only the files that contains features in include, but in each folder from my project i could have a test file and i can not specify every time the each new file only to get the coverage.
Question: Is there a solution to get the coverage only for the main folder or to get the coverage for the files that have already written a spec test? Or to get a coverage for the file that have spec.tsx extension?

Upvotes: 1

Views: 1868

Answers (1)

Please read the documentation, from the above page chose the link to Selecting files for coverage.

Globs are matched using minimatch.

Cypress explains minimatch here.

It's the same as many other places in javascript you will have seen files specified

include: [ '/main/**']

Upvotes: 6

Related Questions