Skip to content

Commit

Permalink
fix: the line with the ignore comment itself should be skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed May 2, 2019
1 parent 7ce4bb1 commit cce4bd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = class CovSource {
_parseIgnoreNext (lineStr, line) {
const testIgnoreNextLines = lineStr.match(/^\W*\/\* c8 ignore next (?<count>[0-9]+)? *\*\/\W*$/)
if (testIgnoreNextLines) {
line.ignore = true
if (testIgnoreNextLines.groups['count']) {
return Number(testIgnoreNextLines.groups['count'])
} else {
Expand Down
4 changes: 3 additions & 1 deletion test/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ describe('Source', () => {
const a = 99
`
const source = new CovSource(sourceRaw, 0)
source.lines[2].ignore.should.equal(false)
source.lines[1].ignore.should.equal(false)
source.lines[2].ignore.should.equal(true)
source.lines[3].ignore.should.equal(true)
})

Expand All @@ -53,6 +54,7 @@ describe('Source', () => {
const a = 99
`
const source = new CovSource(sourceRaw, 0)
source.lines[1].ignore.should.equal(true)
source.lines[2].ignore.should.equal(true)
source.lines[3].ignore.should.equal(true)
})
Expand Down

0 comments on commit cce4bd5

Please sign in to comment.