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
15
votes
2 answers

How do I setup code coverage on my Express based API?

I've been at this problem for a while and I cannot make the existing solutions work for me. I have a Node.js API written in Express.js. I have been writing tests for the API using Mocha, Chai, and Supertest. These test are mostly integration…
Ethan Mick
  • 9,517
  • 14
  • 58
  • 74
15
votes
4 answers

Full Gulp Istanbul Coverage Report

I am using gulp-istanbul to generate JavaScript unit test coverage reports through Gulp. Is there a way to configure Istanbul to generate a full coverage report of all the JS files in my gulp stream, and not just the files touched by a test…
Scott
  • 2,233
  • 2
  • 15
  • 8
14
votes
2 answers

istanbul-instrumenter-loader: coverage issues don't match source

I'm using istanbul-instrumenter-loader to try to generate code coverage reports for my untranspiled es6 code, and while everything runs fine, the issues reported in the generated HTML output doesn't seem to line up with the actual source. For…
tacospice
  • 647
  • 5
  • 20
14
votes
3 answers

Ember CLI and code coverage

Has anyone managed to get code coverage working with an Ember CLI project? I've tried using blanket.js and istanbul, as have others here, here and here, neither with any success. I've managed to get each to actually produce a coverage report but the…
Wungsow
  • 153
  • 1
  • 5
14
votes
3 answers

Istanbul coverage nested directories in HTML report

The unit test coverage report from Istanbul in HTML format displays every single folder of the project in the index.html. It actually flattens the directory structure. Is there an option to render the html report with nested folders?
sod
  • 3,804
  • 5
  • 22
  • 28
13
votes
1 answer

How to run a git pre-commit hook to enforce that test coverage for the staged files doesn't decrease?

I am using jest and istanbul in my ReactJS project to write test cases and check on the test coverage. How do I ensure using a pre-commit hook that test coverage for any file, that I have staged to git, doesn't decrease from its current value before…
Ayan
  • 8,192
  • 4
  • 46
  • 51
13
votes
1 answer

node - how to use source-map with nyc and mocha

So nyc is mangling my files as follows: at _onCreate (src/post/admin.js:1:10453) at doQuery (src/db.js:59:216) at process._tickCallback (internal/process/next_tick.js:68:7) I am unsure of how to use a source map to unmangle this. The docs…
A. L
  • 11,695
  • 23
  • 85
  • 163
13
votes
1 answer

Code Coverage issue when spyon is used

I am writing a unit test for my component(Angular2 app) using Karma-Jasmine. And I am making use of Istanbul for Code Coverage report. Here is my test case, it('Should Invoke onNext function', async(() => { const fixture =…
Vinay
  • 952
  • 2
  • 10
  • 27
13
votes
3 answers

getting nyc/istanbul coverage report to work with typescript

I'm struggling to get proper coverage with nyc/istanbul for my typescript/mocha/gulp project. I've tried a number of approaches, some of them seem to be unable to use source maps and other fails due to ts-node/tsc errors. My current setup is: nyc…
ciekawy
  • 2,238
  • 22
  • 35
13
votes
1 answer

How to specify which functions/methods should be covered by a test, using Karma, Jasmine, and Istanbul

I am trying to figure out how to restrict my tests, so that the coverage reporter only considers a function covered when a test was written specifically for that function. The following example from the PHPUnit doc shows pretty good what I try to…
BillyTom
  • 2,519
  • 2
  • 17
  • 25
13
votes
3 answers

Code Coverage for Typescript using karma-jasmine and istanbul

I am trying to get the Code Coverage for my typescript Code in karma framework using Istanbul in karma.conf typescript files are included and by karma typescript-preprocessor we able to do unit testing and code coverage of the typescript code but…
Udit S. Ahlawath
  • 131
  • 1
  • 1
  • 6
12
votes
0 answers

Vue cli 3 - NYC Istanbul code reports not including vue files

I have been trying for hours now to get the istanbul code coverage reports up and running for my new vue (typescript based) project, generated with the vue-cli v3. Whenever I run my tests: (nodemon --exec nyc vue-cli-service test:unit) only the .ts…
Stan Hurks
  • 1,844
  • 4
  • 14
  • 25
12
votes
1 answer

What does yellow highlighting mean in istanbul?

I just started using istanbul test coverage module for mocha. When I look at the report some code is yellow highlighted. I could not find in the docs what this means?
bier hier
  • 20,970
  • 42
  • 97
  • 166
12
votes
1 answer

How do I extract test coverage from the istanbul text-summary reporter with a regex?

Gitlab CI requires you to specify a regex to extract the statements code coverage (so that they can display it). Given the build output below (with jest and istanbul), I've managed to come as far as: /Statements.*(\d+\%)/ ... (other build…
12
votes
1 answer

Karma produces lcov report for angular project with invalid line numbers

I have an Angular project with some tests. My build is written in Gulp. I run the tests using Karma and produce an lcov report. I then use the gulp-sonar plugin to run Sonar. My sonar config looks like this: "sonar": { "host": { "url":…
wimnat
  • 1,129
  • 1
  • 13
  • 27
1 2
3
41 42