question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nyc config `all:true` does not work

See original GitHub issue

Follow up to #194

Logs and screenshots

✗ DEBUG=code-coverage yarn coverage:integration 
yarn run v1.21.1
$ rm -rf coverage/integration && mkdir -p coverage/integration && yarn cypress run
$ /Users/penx/Development/storybook-code-coverage/node_modules/.bin/cypress run
GVA encoder info: AMD performance mode : 2 
GVA encoder info: deleteSCDMetalContext : texture cache hits: 0, misses: 0

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    4.4.0                                                                              │
  │ Browser:    Electron 80 (headless)                                                             │
  │ Specs:      1 found (spec.js)                                                                  │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    
  Running:  spec.js                                                                         (1 of 1)


  ✓ has a visible header (381ms)
  code-coverage parsed sent coverage +0ms
  code-coverage wrote coverage file /Users/penx/Development/storybook-code-coverage/.nyc_output/out.json +2ms
  code-coverage NYC file /Users/penx/Development/storybook-code-coverage/.nyc_output/out.json has 5 key(s) +0ms
  code-coverage 1 key /Users/penx/Development/storybook-code-coverage/src/utilities/useToggle.js file path /Users/penx/Development/storybook-code-coverage/src/utilities/useToggle.js +0ms
  code-coverage 2 key /Users/penx/Development/storybook-code-coverage/src/design-system/Toggle/index.js file path /Users/penx/Development/storybook-code-coverage/src/design-system/Toggle/index.js +0ms
  code-coverage 3 key /Users/penx/Development/storybook-code-coverage/src/design-system/GlobalStyles/index.js file path /Users/penx/Development/storybook-code-coverage/src/design-system/GlobalStyles/index.js +0ms
  code-coverage in file /Users/penx/Development/storybook-code-coverage/.nyc_output/out.json all files are not found? false +0ms
  code-coverage NYC file /Users/penx/Development/storybook-code-coverage/.nyc_output/out.json has 5 key(s) +2ms
  code-coverage combined NYC options { 'report-dir': './coverage', reporter: [ 'lcov', 'clover', 'json' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: true, all: true, include: [ 'src/**/*.js' ], exclude: [ '**/*.test.js', '**/test.js', '**/*.stories.js', '**/stories.js' ] } +0ms
  code-coverage calling NYC reporter with options { 'report-dir': '/Users/penx/Development/storybook-code-coverage/coverage', reporter: [ 'lcov', 'clover', 'json' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: true, all: true, include: [ 'src/**/*.js' ], exclude: [ '**/*.test.js', '**/test.js', '**/*.stories.js', '**/stories.js' ], tempDir: '/Users/penx/Development/storybook-code-coverage/.nyc_output' } +28ms
  code-coverage current working directory is /Users/penx/Development/storybook-code-coverage +0ms
  code-coverage after reporting, returning the report folder name /Users/penx/Development/storybook-code-coverage/coverage +56ms
  code-coverage Final coverage in /Users/penx/Development/storybook-code-coverage/coverage/coverage-final.json +0ms
  code-coverage ✅ /Users/penx/Development/storybook-code-coverage/src/index.js statements covered 1/1 +0ms
  code-coverage ✅ /Users/penx/Development/storybook-code-coverage/src/application/App.js statements covered 2/2 +0ms
  code-coverage ✅ /Users/penx/Development/storybook-code-coverage/src/design-system/GlobalStyles/index.js statements covered 7/7 +0ms
  code-coverage ✅ /Users/penx/Development/storybook-code-coverage/src/design-system/Toggle/index.js statements covered 5/5 +0ms
  code-coverage ⚠️ /Users/penx/Development/storybook-code-coverage/src/utilities/useToggle.js statements covered 6/10 +1ms

  1 passing (505ms)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     0 seconds                                                                        │
  │ Spec Ran:     spec.js                                                                          │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


  (Video)

  -  Started processing:  Compressing to 32 CRF                                                     
  -  Finished processing: /Users/penx/Development/storybook-code-coverage/cypress/vid    (0 seconds)
                          eos/spec.js.mp4                                                           


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  spec.js                                  497ms        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        497ms        1        1        -        -        -  

✨  Done in 8.89s.

Versions

  • What is this plugin’s version? 3.4.1

  • What is Cypress version? 4.4.0

  • What is your operating system? Mac OS X 10.15.4

  • What is the shell? zsh

  • What is the Node version? 12.14.1

  • What is the NPM version? 6.13.4

  • How do you instrument your application? Cypress does not instrument web application code, so you need to do it yourself.

  • 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 Screenshot 2020-04-21 at 13 04 17

  • 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

Screenshot 2020-04-21 at 13 05 15

  • Do you have any custom NYC settings in package.json (nyc object) or in other NYC config files

Yes, as per ‘describe the bug’ below

  • Do you run Cypress tests in a Docker container?

No

Describe the bug If I have the following in my package.json:

  "nyc": {
    "all": true,
    "include": ["src/**/*.js"],
    "exclude": ["**/*.test.js", "**/*.stories.js"]
  }

I would expect to see files that have 0% coverage in the report, but they don’t appear.

Link to the repo

https://github.com/penx/storybook-code-coverage

^ at present, you will need to update this repo to 3.4.1 and remove "report-dir": "coverage/integration", from package.json (as this setting seems to be bugged in 3.4.1)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bahmutovcommented, Apr 21, 2020

@penx Ha, I just pushed a fix, this was just a silly bug, I forgot existsSync(...) here

const jsonReportFilename = join(folder, 'coverage-final.json')
if (!existsSync) {
  debug('Did not find final coverage file %s', jsonReportFilename)
  return
}
1reaction
bahmutovcommented, Apr 21, 2020

For now, I would not want to add any more specific options to Cypress, so yes, please open a new issue about empty coverage for non-included files, ok.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nyc mocha is generating nothing despite providing nyc config ...
I'm having a bit of trouble using nyc + mocha. My tests are passing but I get no reports, despite adding a nyc...
Read more >
Using Istanbul With TypeScript & mocha
With this configuration, the all: true and cache: true options should work. You will also need to npm install --save-dev source-map-support , which...
Read more >
nyc - npm
Having problems? want to contribute? join our community slack. ... Configuration can also be provided by nyc.config.js if programmed logic ...
Read more >
NYC | Dev Cheatsheets - Michael Currin
I found that setting all was too broad - it checked .eslintrc for example. And I could not get the include value to...
Read more >
Angular - Add Code Coverage to Your Cypress Tests
Cypress does not instrument your code - you need to do it yourself. ... npm install --save-dev @istanbuljs/nyc-config-typescript ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found