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
1
vote
1 answer

Mocha typescript test methods running but nyc not covering those lines of code

I have used nyc for getting code coverage for my nodeJs apis written in typescript. I have written test methods for all apis and controllers. Nyc is configured and working fine for getting coverage for controllers but nyc is not covering API code…
garry
  • 44
  • 5
1
vote
1 answer

How do I run nyc merge from Makefile?

I've inherited a JS code base with Jasmine unit tests. The testing framework uses karma and instanbul-combine to get code coverage. It seems istanbul-combine isn't working with present node modules, and besides is no longer maintained: the…
JohnK
  • 6,865
  • 8
  • 49
  • 75
1
vote
1 answer

Instanbul/Nyc only picking up some files

I tried to set up Istanbul/Nyc/Mocha for test coverage for my project and although I was able to run Nyc successfully, I am only able to see some files being picked up for test coverage not all the .ts files that I have. So when I run npm run…
p0tta
  • 1,461
  • 6
  • 28
  • 49
1
vote
1 answer

nyc report is not uploaded to Codecov in TravisCI build

I have configured codecov to my NodeJS application. When I run the npm run codecov --disable=gcov it generates the reports and I can see the results. But in my TravisCI build, I get a message in the log as X Failed to read file at ==> Scanning for…
Jude Niroshan
  • 4,280
  • 8
  • 40
  • 62
1
vote
2 answers

Mocha not showing count of test cases

I am using mocha, chai, supertest & nyc for my test cases. All of my test cases are working as expected. But I am not able to see the total count of test cases at the end. 21 passing (150ms) // <--- these counts are missing in console 1…
Mohammed Amir Ansari
  • 2,311
  • 2
  • 12
  • 26
1
vote
0 answers

nyc and mocha code coverage failing when running in jenkins

I'm trying to generate the code coverage report for our builds in Jenkins - Locally when I execute the command npm run coverage "scripts": { "test": "cross-env mocha test -t 5000 --recursive --exit --reporter mochawesome", …
1
vote
1 answer

How to get an overview of all files in a directory using Istanbul / nyc?

I just started using nyc and Istanbul to generate a code coverage report. The fist thing I notest was that the coverage report only shows the coverage for files that are addressed in the tests. It does not show any coverage for files that are not…
SomeDutchGuy
  • 2,249
  • 4
  • 16
  • 42
1
vote
1 answer

mocha nyc and source maps

So. I am trying to get my head around why this isn't working. I am writing source and test TypeScript code in files in the src and tests directory. These are *.ts and *.spec.ts files. I use npx tsc to transpile both the source and test files to the…
basickarl
  • 37,187
  • 64
  • 214
  • 335
1
vote
1 answer

How to test async calls so istanbul will cover it?

Im testing unit-testing my API. After i wrote all tests i implemented coverage tool istanbul. It covered everything without problems but branches. After looking at report i saw that async calls were not tested, but in reality they were run atleast 5…
Zeeecho
  • 85
  • 9
1
vote
1 answer

nyc runtime coverage with cucumber

I am trying to get coverage for my e2e tests written in cucumber/TS, but my test report is never able to map back to my source files. The report is just a list of directories, and clicking into individual *.ts files yields a stacktrace (***'d out my…
Dragan R.
  • 598
  • 4
  • 18
1
vote
1 answer

Specifying the location of mocha.opts when running mocha with nyc?

Is it possible to specify the location of mocha.opts when running nyc mocha? I'd like to have it in the root project folder. I tried this in my npm script: "scripts": { "test": "nyc mocha --config ./mocha.opts" }, That did not work. I did get…
Ole
  • 41,793
  • 59
  • 191
  • 359
1
vote
1 answer

how to run code coverage of client side javascript with npm scripts

I have a client side web application written in basic javascript that should run in a modified chromium browser inside another application. The code is extensively refactored to work in the current setup and updated to use ES6 features. The old…
hepabolu
  • 1,214
  • 4
  • 18
  • 29
1
vote
0 answers

Istanbul / nyc code coverage issues

I'm using ExpressJS and have created unit tests with mocha along with coverage using istanbul nyc. I have implemented a route (see code below) and am verifying code coverage of my tests. The following registers as 100% covered, import express from…
1
vote
1 answer

ES6 Istanbul code coverage : how to test correctly a branch

I don't understand how the test coverage is processing this .catch() branch : newUser.save() .then((savedUser) => { res.json(savedUser); }) .catch( (e) => { if (e.name === 'ValidationError' && e.errors.username.kind…
user762579
1
vote
0 answers

ES6 code coverage nyc/mocha why this line is marked as not covered ? even if fun is run

I would like to know why this ES6 line is marked as non covered: package.json .... "test:v1:coverage": "cross-env NODE_ENV=test ./node_modules/.bin/nyc _mocha --timeout 15000 --ui bdd --colors --compilers js:babel-core/register server/v1/tests…
user762579