Skip to content

Commit

Permalink
fixup! Support reporting coverage for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Tatarintsev committed Nov 18, 2014
1 parent a4dbf9e commit 42c6bdd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
23 changes: 10 additions & 13 deletions lib/coverage-object.js
@@ -1,14 +1,14 @@
var _ = require('lodash');
var _ = require('lodash'),
inherit = require('inherit');

function CoverageObject() {
this._indices = {
};
this.coverage = {
};
}
module.exports = inherit({
__constructor: function() {
this._indices = {
};
this.coverage = {
};

CoverageObject.prototype = {
constructor: CoverageObject,
},

addStatement: function (start, end, counter) {
var sourceName = start.source,
Expand Down Expand Up @@ -75,11 +75,8 @@ CoverageObject.prototype = {
}
return fileObject;
}

};
});

function getLocation(soureMapLocation) {
return _.pick(soureMapLocation, 'line', 'column');
}

module.exports = CoverageObject;
1 change: 0 additions & 1 deletion lib/plugin.js
Expand Up @@ -60,7 +60,6 @@ module.exports = function (helper) {
sourceLevels: options.sourceLevels || options.levels,
coverage: _.defaults(options.coverage || {}, {
engines: [],
hasSourceMap: false,
reportDirectory: 'tmpl-coverage',
exclude: [
'**/node_modules/**',
Expand Down
4 changes: 0 additions & 4 deletions lib/runner.js
Expand Up @@ -66,10 +66,6 @@ function getReporters() {
function processCoverage(coverageOpts) {
var coverage = global.__coverage__;

if (!coverageOpts.hasSourceMap) {
return filterAndSaveCoverage(coverage, coverageOpts);
}

return unmapCoverageObject(coverage)
.then(function (unmapedCoverage) {
return filterAndSaveCoverage(unmapedCoverage, coverageOpts);
Expand Down
8 changes: 7 additions & 1 deletion lib/unmap-coverage.js
Expand Up @@ -17,9 +17,15 @@ function unmapCoverageObject(sourceObject) {
return coverageObjects.reduce(istanbul.utils.mergeFileCoverage);
})
.then(function (totalCoverage) {
return _.omit(totalCoverage, function (value, fileName) {
var withNoSources = _.omit(totalCoverage, function (value, fileName) {
return fileName in sourceObject;
});
if (_.isEmpty(withNoSources)) {
// if no sources left after removal of originals,
// source map is absent
return totalCoverage;
}
return withNoSources;
});
}

Expand Down

0 comments on commit 42c6bdd

Please sign in to comment.