1

I have tried so many plugins for writing gulp task to generate coverage report in Angular 4 but no-one was working. All documentation is for javascript files and in angular 4 we have typescript files. Once I tried converting all my ts files to js files using gulp typescript and then passed those javascript references in gulp source, but finally it ends with errors.

Is there any plugin for angular 2+ to generate coverage report through gulp?

Thank you!

arctic_Oak
  • 974
  • 2
  • 13
  • 29
  • why you need gulp to generate report? you can use karma to generate reports. – rijin Jan 16 '18 at 06:46
  • yes I can but in my gulp I want to add all tasks like checking for lint errors, documentation using typedoc and then generating coverage report. So, that in just one command "gulp" everything will get done. I don't want to do all these things separately. – arctic_Oak Jan 16 '18 at 06:49
  • ng test --code-coverage will give you coverage report. try to run this command with gulp – rijin Jan 16 '18 at 08:00
  • I know that using gulp-exec I can run commands but I want to use some plugin specific to that. If I implement executing command it's like finding substitute for this task. – arctic_Oak Jan 16 '18 at 08:02
  • and I know that there must be some plugin or I need to implement something more inside the existing one like gulp istanbul, gulp coverage – arctic_Oak Jan 16 '18 at 08:04
  • or just tell me whether my approach is correct or not that converting ts to js first and then try some plugin?? – arctic_Oak Jan 17 '18 at 04:06

1 Answers1

0

I found one solution for that using gulp-exec.

In gulp-exec we can run any command.

https://www.npmjs.com/package/gulp-exec

var exec = require('child_process').exec;

gulp.task('task', function (cb) {
  exec('ng test -cc', function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    cb(err);
  });
})
arctic_Oak
  • 974
  • 2
  • 13
  • 29