willembult / mocha-phantomjs-istanbul

Collect istanbul coverage from instrumented client-side Mocha tests with PhantomJS
MIT License
8 stars 3 forks source link

how can i merge any report in one? #4

Open smildlzj opened 7 years ago

smildlzj commented 7 years ago

hi, my project use webpack as build tools,so some mobules was import by any pages.

but the coverage report is worng , and overwrite by the last test file.

gulp
    .src('./build/**/*.test.html', {read: false})
    .pipe(mochaPhantomJS({
      reporter: 'list',
      phantomjs: {
        settings : {
          localToRemoteUrlAccessEnabled : true,
          webSecurityEnabled : false,
        },
        useColors: true,
        viewportSize : {
          width: 800,
          height: 600
        },
        hooks: 'mocha-phantomjs-istanbul',
        coverageFile: './coverage/coverage.json'
      }
    }))
    .on('finish', function() {
      gulp.src('./coverage/coverage.json')
        .pipe(istanbulReport({
          reporterOpts: {
            dir: './coverage'
          },
          reporters: ['html']
        }))
    });
smurfpandey commented 6 years ago

I have made few tweaks in my fork to handle this use-case. Now the coverage report from each test gets appended in the coverageFile. You can check the changes here: https://github.com/smurfpandey/mocha-phantomjs-istanbul