Questions tagged [nyc]

a command-line interface for the Istanbul code coverage tool.

nyc is a command-line interface for the Istanbul code coverage tool.

147 questions
7
votes
5 answers

nyc + mocha + es6 modules

I am trying to use nyc + mocha to get test coverage on my unit tests that uses the es6 module syntax. When I run mocha my_test.mjs everything works fine. The dependencies within my_test.mjs (using native import) are resolved correctly. But when I…
blaizard
  • 216
  • 2
  • 8
7
votes
1 answer

Yarn installed nyc successfully, but zsh says "command not found"

Question: How do I make nyc visible to zsh? Steps to recreate: I tried yarn add nyc -g (I was following steps that used npm so I just replaced npm i with yarn add) Then ran nyc report --reporter=html zsh: command not found: nyc However, when I…
Marlo
  • 490
  • 3
  • 7
  • 21
7
votes
1 answer

nyc (istanbul) exclude test code from coverage reports

I'm trying to add coverage report generation to a typescript library project. The layout includes these directories: project ├─ src │ ├─ lib ## project code (typescript), *.tsx │ ├─ test ## test specs (typescript), *.spec.tsx │ └─ @types…
ShadSterling
  • 1,792
  • 1
  • 21
  • 40
6
votes
0 answers

Generating nyc coverage report for VueJS project with @vue/cli-plugin-unit-mocha, TypeScript and SFC's

I am currently working on setting up a testing environment for a Vue project that uses the @vue/cli-plugin-unit-mocha to run unit tests. The project uses TypeScript and .vue Single-File-Components. I have successfully set-up my project to run unit…
6
votes
1 answer

TypeScript: Could not find a declaration file for module in unit tests, only

I'm using TypeScript with Visual Studio Code on Windows 10 to develop an NPM module. I use mocha/chai combined with nyc (istanbul) for unit testing and code coverage. For some of my tests I would like to use chai-bytes to compare buffers more…
Michael Schröder
  • 166
  • 1
  • 1
  • 8
5
votes
1 answer

Get zero coverage with nyc and playwright

I'm struggling to set up coverage correctly using Playwright. It reports 0 coverage in all files (except the test files themselves, if I include them). I'm getting inspiration from https://playwright.dev/docs/api/class-coverage and…
jorgen
  • 3,425
  • 4
  • 31
  • 53
5
votes
1 answer

@cypress/code-coverage Can't resolve '../self-coverage-helper' @cypress

I try to run in index.js of Cypress: require('@cypress/code-coverage/task') Getting this error: Module not found: Error: Can't resolve '../self-coverage-helper' in…
Tobi
  • 109
  • 1
  • 1
  • 12
5
votes
2 answers

Angular + Cypress code coverage reporting not working

I have been trying to get Cypress code coverage working with my Angular production project to no avail. To try and help diagnose it, I have created a minimal implementation project to make sure I wasn't introducing anything weird in the production…
Monkeeman69
  • 502
  • 2
  • 5
  • 18
5
votes
0 answers

nyc coverage reports empty with babel mocha

I am using mocha to unit test my js code which is using babel also. I am using nyc to do coverage. But in the end, the result is showing empty. Why does it show All files 0 even though my test file is requiring redux.js and number-reducer.js files…
Mani
  • 1,364
  • 14
  • 33
5
votes
1 answer

How to get combined coverage on both unit test and integration test using NYC

I want to get a combined coverage of both unit-test and integration-test. I have seperate folders for both unit-test and integration-test. In my pipeline ci i have a seperate stage for unit-test and integration-test becasue the integration-test…
Kay
  • 17,906
  • 63
  • 162
  • 270
5
votes
0 answers

How to collect code coverage for spawned sub-processes using Jest?

I am writing integration tests for a CLI. All the unit tests are written using Jest as out-of-the-box it produces code coverage without any configuration, but unfortunately it does not instrument sub-processes, for example executed via Node's spawn…
sdgluck
  • 24,894
  • 8
  • 75
  • 90
5
votes
1 answer

nyc equivalent of istanbul command

I am trying to convert my istanbul code coverage commands to nyc. It appears as though nyc is now the command line interface for the istanbul test coverage library. With istanbul, we'd get coverage like so: istanbul cover foo.js --dir coverage then…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
5
votes
1 answer

NYC report output different on Jenkins vs local environment

I have something strange happening when attempting to generate a combined coverage report on a Jenkins pipeline job. I have an Nx powered Angular monorepo and am generating coverage reports across all the libs and projects contained within. I have…
mindparse
  • 6,115
  • 27
  • 90
  • 191
4
votes
1 answer

How to get code coverage of nodejs application without having to write test cases in recommended frameworks?

Its recommended to use frameworks like Mocha, chai or jest to make use of istanbul to get code coverage. I have designed a testing tool, which will send a request to a api and based on the response, it will be termed as pass or fail. The payload and…
Elson D'Sa
  • 99
  • 2
  • 9
4
votes
0 answers

How to create a nyc coverage report for all tests including main and renderer in Electron (and GitLab)

I struggle to get the code coverage working for all tests in electron, that i wanne use for the gitlab coverage. Situation The tests are working and for each test-script I get a nice report. Same on GitLab pipeline, when i push a commit. Problem I…
PxlCode
  • 51
  • 6
1
2
3
9 10