Skip to content

Commit

Permalink
fix: update to work with Karma 0.11
Browse files Browse the repository at this point in the history
Since Karma executes immediately, we don't have all the browsers in advance, the reporter has to listen on browser_start instead.

This re-introduces b744d6f but in a back-compatible way.
  • Loading branch information
vojtajina committed Nov 29, 2013
1 parent 9b78280 commit 89c9817
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 12 additions & 4 deletions lib/reporter.js
Expand Up @@ -64,10 +64,18 @@ var CoverageReporter = function(rootConfig, helper, logger) {
}

this.onRunStart = function(browsers) {
collectors = {};
browsers.forEach(function(browser) {
collectors[browser.id] = new istanbul.Collector();
});
collectors = Object.create(null);

// TODO(vojta): remove once we don't care about Karma 0.10
if (browsers) {
browsers.forEach(function(browser) {
collectors[browser.id] = new istanbul.Collector();
});
}
};

this.onBrowserStart = function(browser) {
collectors[browser.id] = new istanbul.Collector();
};

this.onBrowserComplete = function(browser, result) {
Expand Down
3 changes: 2 additions & 1 deletion test/reporter.spec.coffee
Expand Up @@ -120,7 +120,8 @@ describe 'reporter', ->
fakeOpera = makeBrowser 'bbb', 'Opera/9.80 Mac OS X Version/12.00', browsers, emitter
browsers.add fakeChrome
browsers.add fakeOpera
reporter.onRunStart browsers
reporter.onRunStart()
browsers.forEach (b) -> reporter.onBrowserStart b
mockFs.writeFile.reset()
mockMkdir.reset()

Expand Down

0 comments on commit 89c9817

Please sign in to comment.