1

I am working on a NodeJS project, chai framework is been used for the unit testing and istanbul is been used for the code coverage.

I wanted to integrate the istnabul code coverage into the Jenkins. I have googled regarding the same, but couldn't get much of the information regarding this integration.

What is the best way/best jenkins plugins available to integrate the istanbul code coverage into jenkins?

Bala Subramanyam
  • 185
  • 1
  • 2
  • 17

1 Answers1

3

I recommend using Cobertura plugin to publish the reports in Jenkins.

I have an application with Angular and Karma for Unit Testing and the test coverage is performed with Istanbul. For this application, the step to publish the tests in Jenkins with Cobertura looks like this:

    stage("Code Coverage") {
        steps {
            script {
                sh "npm run ng -- test --karma-config ./src/karma.conf.js --code-coverage"
            }
        }
        post {
            always {
                step([$class: 'CoberturaPublisher', coberturaReportFile: '**/coverage/MyApp/cobertura-coverage.xml'])
            }
        }
    }

I have used this article on Medium, maybe you can find other useful information there as well.

  • For those of you who decide to use this plugin, an example of the newer Pipeline syntax can be found here: https://stackoverflow.com/a/53838669/3513260 – Fearnbuster Jan 18 '22 at 16:45