dwyl / learn-istanbul

:checkered_flag: Learn how to use the Istanbul JavaScript Code Coverage Tool
339 stars 41 forks source link

How to cover all the files in the directory recursively #11

Open aamin3189 opened 7 years ago

aamin3189 commented 7 years ago

How to cover all the files in the directory recursively

nelsonic commented 7 years ago

@aamin3189 great question! the easiest way to do this is to use an .istanbul.yml file, do you already have one?

aamin3189 commented 7 years ago

Thanks @nelsonic . After a little digging I have found that we can write a gulp task to generate coverage report for all the files,

var gulp = require('gulp');
var istanbul = require('gulp-istanbul');

gulp.task('test', function () {
    return gulp.src(['./test/**/*.js'])
      // Right there
      .pipe(istanbul({includeUntested: true}))
      .on('finish', function () {
        gulp.src(['./test/**/*.js'])
          .pipe(istanbul.writeReports({
            dir: './coverage',
            reporters: [ 'lcov' ],
            reportOpts: { dir: './coverage'}
          }));
      });
  });
nelsonic commented 7 years ago

@aamin3189 that should do the trick if you are already using gulp for your build tasks. 👍