gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 787 forks source link

Istanbul instrument converts all function names to anonymous #709

Open qea5ae opened 8 years ago

qea5ae commented 8 years ago

Hello, I am using istanbul to get the converage information. I am following below steps

  1. Instrument the JS code using gulp-istanbul

gulp.task('coveragewar', function () { return gulp.src([ process.env.ROOT + '/out/war/dev/assets/js/*/_.js' ]) // Covering files .pipe(istanbul({ // supports es6 coverageVariable: 'Coverage', noAutoWrap: true

})) .pipe(gulp.dest(process.env.ROOT + '/out/war/dev/assets/js/')) // Force require to return covered files .pipe(istanbul.hookRequire());

});

Now when I am running my tests at the end I read the coverage variable as given below: Object test = js.executeScript( "var coverageJson = window.Coverage;return JSON.stringify(coverageJson);" ); //$NON-NLS-1$

In this I am reading fnMap from coverageJson which has all anonymous function names. I set " noAutoWrap: true" in order to stop auto wrapping of functions but it did not help. This is really blocking me as I need the real method/function names rather than these anonymous names.

Can anyone help me to understand how can we avoid this name wrapping during instrumentation.?