In the initial state I have e.g. app.module.js with the following code of Angular application:
'use strict';
var app = angular.module('bumblebee', []);
In order to get test coverage for e2e protractor tests I apply the gulp-istanbul
.
gulp.task('decorate:code:istanbul', function() {
return gulp.src('./app/')
.pipe(istanbul({
includeUntested: true,
coverageVariable: '__coverage__'
}))
.pipe(gulp.dest(./app/));
});
What this does is it digests all my files with istanbul so they will have code coverage decoration inside, like my file app.module.js:
"use strict";
var __cov_BJkerWMhn194664Vc2WfiA = (Function('return this'))();
if (!__cov_BJkerWMhn194664Vc2WfiA.__coverage__) {
__cov_BJkerWMhn194664Vc2WfiA.__coverage__ = {};
}
__cov_BJkerWMhn194664Vc2WfiA = __cov_BJkerWMhn194664Vc2WfiA.__coverage__;
if (!(__cov_BJkerWMhn194664Vc2WfiA['c:\\project\\app.js'])) {
__cov_BJkerWMhn194664Vc2WfiA['c:\\project\\app.js'] = {
"path": "c:\\project\\app.js",
"s": {"1": 0, "2": 0},
"b": {},
"f": {"1": 0},
"fnMap": {
"1": {
"name": "(anonymous_1)",
"line": 6,
"loc": {"start": {"line": 6, "column": 9}, "end": {"line": 6, "column": 20}}
}
},
"statementMap": {
"1": {"start": {"line": 3, "column": 0}, "end": {"line": 3, "column": 171}}
},
"branchMap": {}
};
}
__cov_BJkerWMhn194664Vc2WfiA = __cov_BJkerWMhn194664Vc2WfiA['c:\\project\\app.js'];
__cov_BJkerWMhn194664Vc2WfiA.s['1']++;
var app = angular.module('bumblebee', []);
Then after running the tests and getting the source code coverage I want to remove all this additional information from app.module.js. Is there a way to do this?
P.S. Currently I'm copying all source to new directory, instrument it with istanbul, run e2e tests for this instrumented code, get code coverage and use it as for original code. This is not very efficient in my opinion.