Skip to content

Commit

Permalink
don't skip annotating node unless fully bypassed (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedireza authored and geek committed Aug 14, 2016
1 parent 7236bbd commit 06b57f9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ internals.instrument = function (filename) {

// Coverage status

if (bypass[node.range[0]]) {
if (bypass[node.range[0]] && bypass[node.range[1]]) {
return;
}

Expand Down
13 changes: 13 additions & 0 deletions test/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ describe('Coverage', () => {
done();
});

it('bypasses marked code and reports misses correctly', (done) => {

const Test = require('./coverage/bypass-misses');
Test.method(1);

const cov = Lab.coverage.analyze({ coveragePath: Path.join(__dirname, 'coverage/bypass-misses') });
expect(Math.floor(cov.percent)).to.equal(93);
expect(cov.sloc).to.equal(15);
expect(cov.misses).to.equal(1);
expect(cov.hits).to.equal(14);
done();
});

it('ignores non-matching files', (done) => {

require('./coverage/exclude/ignore');
Expand Down
27 changes: 27 additions & 0 deletions test/coverage/bypass-misses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

// Load modules


// Declare internals

const internals = {};

/*$lab:coverage:off$*/const noop = function () {};

const /*$lab:coverage:on$*/FiveMath = function () {

this.addFive = function (value) {

return value + 5;
};

this.subtractFive = function (value) {

return value - 5;
};
};

const fiveMath = new FiveMath();

exports.method = fiveMath.addFive;

0 comments on commit 06b57f9

Please sign in to comment.