-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(in-memory-reporter) Added a new reporter in-memory which will ra…
…ise an event rather than write to disk
- Loading branch information
Showing
6 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
function InMemoryReport (opt) { | ||
this.browser = opt.browser | ||
this.emitter = opt.emitter | ||
} | ||
|
||
InMemoryReport.prototype.writeReport = function (collector, sync) { | ||
this.emitter.emit('coverage_complete', this.browser, collector.getFinalCoverage()) | ||
} | ||
|
||
InMemoryReport.TYPE = 'in-memory' | ||
|
||
module.exports = InMemoryReport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
InMemoryReport = require '../lib/in-memory-report' | ||
|
||
describe 'InMemoryReport', -> | ||
|
||
emitter = | ||
emit: sinon.stub() | ||
browser = { name: 'firefox' } | ||
result = { coverage: 'result' } | ||
collector = | ||
getFinalCoverage: sinon.stub().returns result | ||
|
||
it 'should raise an "coverage_complete" event.', -> | ||
sut = new InMemoryReport { browser: browser, emitter: emitter} | ||
sut.writeReport collector | ||
expect(collector.getFinalCoverage).to.have.been.called | ||
expect(emitter.emit).to.have.been.calledWith('coverage_complete', browser, result) | ||
|
||
it 'should be of type "in-memory"', -> | ||
expect(InMemoryReport.TYPE).to.be.equal('in-memory') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
index = require '../lib/index' | ||
InMemoryReport = require '../lib/in-memory-report' | ||
istanbul = require 'istanbul' | ||
|
||
describe 'Index', -> | ||
it 'should register "InMemoryReport" to istanbul', -> | ||
expect(istanbul.Report.create('in-memory', {})).to.be.an.instanceof(InMemoryReport) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters