Skip to content

Commit

Permalink
Merge pull request #219 from nicojs/bug-property-browser-of-undefined
Browse files Browse the repository at this point in the history
fix(in-memory-reporter): Fix bug in new InMemoryReport, now using null-checks
  • Loading branch information
dignifiedquire committed Mar 7, 2016
2 parents fbca762 + 051cffd commit 39bbf3c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/in-memory-report.js
@@ -1,11 +1,18 @@
var Report = require('istanbul').Report
var util = require('util')

function InMemoryReport (opt) {
this.browser = opt.browser
this.emitter = opt.emitter
this.opt = opt
}

util.inherits(InMemoryReport, Report)

InMemoryReport.prototype.writeReport = function (collector, sync) {
this.emitter.emit('coverage_complete', this.browser, collector.getFinalCoverage())
if (!this.opt.emitter || !this.opt.emitter.emit) {
console.error('Could not raise "coverage_complete" event, missing emitter because it was not supplied during initialization of the reporter')
} else {
this.opt.emitter.emit('coverage_complete', this.opt.browser, collector.getFinalCoverage())
}
}

InMemoryReport.TYPE = 'in-memory'
Expand Down
7 changes: 7 additions & 0 deletions test/in-memory-report.spec.coffee
@@ -1,4 +1,5 @@
InMemoryReport = require '../lib/in-memory-report'
istanbul = require 'istanbul';

describe 'InMemoryReport', ->

Expand All @@ -17,3 +18,9 @@ describe 'InMemoryReport', ->

it 'should be of type "in-memory"', ->
expect(InMemoryReport.TYPE).to.be.equal('in-memory')

it 'should not fail when created without arguments', ->
expect(new InMemoryReport()).to.be.ok

it 'should inherit from Report', ->
expect(new InMemoryReport()).to.be.an.instanceof(istanbul.Report)

0 comments on commit 39bbf3c

Please sign in to comment.