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

Trying to make Cypress, TypeScript and IstanbulJS work together

I am trying to generate code coverage reports with IstanbulJS for my code written in TypeScript and tested with Cypress. But things get reported out of place: I created a git repository MCVE specifically for this question, so you can reproduce…
Pedro A
  • 3,989
  • 3
  • 32
  • 56
11
votes
1 answer

How does SonarQube calculate the overall coverage?

The image above shows the SonarQube coverage for one of my folders, but if you take the average of the percentages of all files in that folder, it will amount to 49%, yet SonarQube will display 31.4%. If not by taking averages, how does SonarQube…
11
votes
2 answers

Angular2 - http call Code coverage

My components.ts is, getHomePageData() : void{ this.homeservice.getHomePageData() .subscribe( data => { //console.log("response status ################### "+data.status); …
Human Being
  • 8,269
  • 28
  • 93
  • 136
11
votes
2 answers

Istanbul branch coverage is ES6 class should be 100% but is only 75%

I have written a very simple class and some unit tests. The coverage report should be 100% but I see 75% for branches. I can't figure out how to get to 100% and where I should be looking to understand what I'm missing. UPDATE Unit tests: /* global…
Thomas Amar
  • 352
  • 10
  • 20
11
votes
2 answers

Webpack Karma Istanbul Remapping for TypeScript

I'm developing a client-side app and I'm having trouble with creating the right Karma configs. Right now, I have my setup as follows: Webpack: Using ts-loader, compiles TypeScript, assets etc. Karma: Using the webpack plugin, loads the Webpack…
calclavia
  • 321
  • 1
  • 5
  • 10
11
votes
2 answers

Generate two coverage reports in a single jenkins build

I have a Jenkins build which build all my java/angularJS project. It launch testNG tests for the java part and karma tests for the javascript part. So I can generate one testNG report (for java) and one junit report (for karma test) in my Jenkins…
clement
  • 489
  • 1
  • 5
  • 18
11
votes
2 answers

Event callback's code coverage

I use Karma (currently v0.10.10) and Jasmine for my unit tests, and Istanbul (via karma-coverage) for code coverage reports. I've noticed a strange behaviour of the code coverage reporter in a particular case. The code I'm trying to test is roughly…
mingos
  • 23,778
  • 12
  • 70
  • 107
10
votes
1 answer

How do I get Istanbul to recognize code coverage when using ESM?

I'm using ESM to loading my modules and I use them in this way: // More info on why this is needed see (https://github.com/mochajs/mocha/issues/3006) async function wire(){ await import("./Sanity.spec.mjs"); await…
JGleason
  • 3,067
  • 6
  • 20
  • 54
10
votes
2 answers

if-else path not taken in imports in angular istanbul code coverage report

import { Component, OnInit } from '@angular/core'; import { Title } from '@angular/platform-browser'; @Com(I)ponent({ selector: 'app-fruit-cake',(E) templateUrl: './fruit-cake.component.html', styleUrls:…
Vishal Anand
  • 1,431
  • 1
  • 15
  • 32
10
votes
1 answer

Istanbul gives me coverage but ends output with an error

I'm testing out a simple application (from the Mocha tutorial code here https://marcofranssen.nl/using-mocha-chai-sinon-to-test-node-js/) to try to get Istanbul to work. My problem is that Istanbul works fine to give me a coverage summary, but then…
user3180077
  • 633
  • 1
  • 8
  • 16
9
votes
3 answers

How to generate nyc report from json results (no .nyc_output)?

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
9
votes
3 answers

How to improve puppeteer startup performance during tests

I've written a small crawler with the help of Puppeteer. Now I'm facing the challenge that my tests are rather slowly (> 3 seconds for each test). I've been able to track it down to the launch function of Puppeteer and the usage of…
seasick
  • 473
  • 1
  • 4
  • 15
9
votes
1 answer

Is there a way to generate Jest / Istanbul coverage report in junit.xml format

I'd like to use Gitlab CI for tracking / embedding the coverage analysis in merge requests. The gitlab-ci.yml artifacts:reports:junit config option seems to be suitable for this task. However, this requires the coverage output to be in junit.xml…
lipp
  • 5,586
  • 1
  • 21
  • 32
9
votes
2 answers

SonarQube and Lcov report Could not resolve file paths

We are trying to make a SonarQube code coverage report for our angular application. We have used Karma to generate a code coverage report and import it into SonarQube analyzer. The SonarQube already has C# coverage for our project, now we want to…
Murali Murugesan
  • 22,423
  • 17
  • 73
  • 120
9
votes
0 answers

Istanbul.js in the browser

Mocha and chai can be used seamlessy in the browser. You import them with the script tag, import your test script and in the browser you end up having a nice summary of the results. This also makes it trivial to test libraries that manipulate the…
pistacchio
  • 56,889
  • 107
  • 278
  • 420