Skip to content

Commit

Permalink
Merge pull request #25 from jasisk/reporter-array-support
Browse files Browse the repository at this point in the history
add reporter array support
  • Loading branch information
bcoe committed Jun 4, 2015
2 parents 29f9258 + 9cd4fb8 commit 28972ad
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ NYC.prototype.report = function (_collector, _reporter) {
collector.add(report)
})

reporter.add(this.reporter)
if (Array.isArray(this.reporter)) {
this.reporter.forEach(function (_reporter) {
reporter.add(_reporter)
})
} else {
reporter.add(this.reporter)
}

reporter.write(collector, true, function () {})
}
Expand Down
31 changes: 31 additions & 0 deletions test/nyc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,37 @@ describe('nyc', function () {
)
})
})

it('handles multiple reporters', function (done) {
var reporters = ['text-summary', 'text-lcov'],
incr = 0,
nyc = new NYC({
cwd: process.cwd(),
reporter: reporters
}),
proc = spawn(process.execPath, ['./test/fixtures/sigint.js'], {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit'
})

proc.on('close', function () {
nyc.report(
{
add: function (report) {}
},
{
add: function (reporter) {
incr += !!~reporters.indexOf(reporter)
},
write: function () {
incr.should.eql(reporters.length)
return done()
}
}
)
})
})
})

describe('.istanbul.yml configuration', function () {
Expand Down

0 comments on commit 28972ad

Please sign in to comment.