Questions tagged [istanbul]

A JavaScript code coverage tool written in JavaScript.

The Istanbul 2.0 API is now available and is being actively developed in the new istanbuljs organization.

Istanbul - a JavaScript code coverage tool written in JavaScript

Features

  • All-JavaScript instrumentation library that tracks statement, branch, and function coverage.
  • Module loader hooks to instrument code on the fly
  • Command line tools to run node unit tests "with coverage turned on" and no cooperation whatsoever from the test runner
  • Multiple report formats: HTML, LCOV, Cobertura, and more.
  • Ability to use as middleware when serving JavaScript files that need to be tested on the browser.
  • Can be used on the command line as well as a library
  • Based on the awesome esprima parser and the equally awesome escodegen code generator
  • Well-tested on Node.js (prev, current and next versions) and the browser (instrumentation library only)
624 questions
24
votes
4 answers

How to make Istanbul generate coverage for all of my source code?

Currently Istanbul is only generating coverage for files that are used in my tests, which is okay, but seems to defeat the purpose of having coverage somewhat. I have no Istanbul configuration, and am invoking it via npm test with the following…
Seer
  • 5,226
  • 5
  • 33
  • 55
23
votes
1 answer

sending arguments to test script with istanbul

I'm trying to see my Mocha test code coverage with istanbul, but I need to supply the --recursive arguments to the test script _mocha, because else it only runs the tests in the test directory. I tried istanbul cover "_mocha --recursive" but it says…
Ygg
  • 3,798
  • 1
  • 17
  • 23
22
votes
3 answers

How to get code coverage information using Node, Mocha

I've recently started getting into unit testing for my Node projects with the help of Mocha. Things are going great so far and I've found that my code has improved significantly now that I'm thinking about all the angles to cover in my tests. Now,…
Chris Wright
  • 754
  • 1
  • 8
  • 19
20
votes
6 answers

No coverage nyc mocha

I am just unable to figure out why test coverage is 0 even though test case is passing. I have a script in package.json: "nyctest": "node --max_old_space_size=4096 node_modules/nyc/bin/nyc.js --reporter=text mocha" When I run npm run nyctest My…
Faraz
  • 6,025
  • 5
  • 31
  • 88
19
votes
1 answer

Istanbul code coverage : how to ignore such lines?

when performing code coverage , all my .catch() statements are uncovered, is there a way to specify /* istanbul ignore next */ somewhere ? ex : function list(req, res, next) { const { limit = 50, skip = 0 } = req.query; User.list({ limit, skip…
user762579
18
votes
1 answer

Code Coverage on React with Puppeteer + Istanbul

I have an app created with create-react-app and some UI tests written in Jest + Istanbul. I want to get code coverage of these UI tests. I like to keep using jest as I already use it for unit-tests. I'd like not to eject create-react-app if at all…
bhathiya-perera
  • 1,303
  • 14
  • 32
18
votes
0 answers

How to do code coverage with karma, typescript, and browserify

How do you setup karma test runner to generate code coverage reports of a typescript project? Given the following folder structure and karma.conf.js file I'm already using karma to run my tests written in TypeScript. I already fiddled around with…
Oliver
  • 978
  • 6
  • 17
18
votes
2 answers

Istanbul how to ignore default value branch for ES6 (babel compiles to ES5)

In ES5 we can write like this: function(a){ /* istanbul ignore next */ a = a || 123; } how to ignore In ES6? function(a = 123 ){ } I tried this: function(/* istanbul ignore next */a = 123 ){ } but it's not working.
Sabrina Luo
  • 3,810
  • 4
  • 16
  • 35
18
votes
4 answers

Exclude function (not an entire file) from JavaScript code coverage

I'm creating some unit tests with Jasmine and the test runner I'm using is Karma. I'm also checking the code coverage of these test specs with the karma-coverage plugin. I was wondering if there's any way of excluding certain functions from the…
Marcel N.
  • 13,726
  • 5
  • 47
  • 72
17
votes
3 answers

What is instrumentation in nyc istanbul?

What is instumentation used in nyc? nyc's instrument command can be used to instrument source files outside of the context of your unit-tests: I assume it will do coverage outside unit-testing. I tried it with nyc instrument src…
otong
  • 1,387
  • 2
  • 17
  • 28
16
votes
1 answer

Should .nyc_output be included in .gitignore?

Do we need to include .nyc_output or should we just put that directory in .gitignore
Ole
  • 41,793
  • 59
  • 191
  • 359
15
votes
3 answers

Include component template in unit test coverage with Angular

With Angular 4 it is possible to test the Component's template, for example checking if clicking a button triggers the expected method and stuff like that. But how can templates be included in the test coverage? By default they are not (using…
Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
15
votes
1 answer

what does 1x 3x etc mean in karma code coverage report in Angular Unit testing?

I am new to Unit Testing in Angular. I got the karma setup with code coverage along with angular-cli . I have run the command ng-test and opened code coverage report. I saw 1x ,3x etc along with my code line numbers in that coverage report. Please…
15
votes
3 answers

Istanbul code coverage for Mocha tests

I am trying to get Istanbul to work. I keep getting this message at the end of running istanbul: No coverage information was collected, exit without writing coverage information I have tried everything I could find online as you can see: …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
15
votes
4 answers

How to cover React jsx files in Istanbul?

I'm trying to integrate my existing test processes to now include React, but am struggling on the code coverage part. I've been able to get my unit tests working fine by following this project/tutorial - https://github.com/danvk/mocha-react - …
Justin Maat
  • 1,965
  • 3
  • 23
  • 33
1
2
3
41 42