Skip to content

Commit 89c9817

Browse files
committed
fix: update to work with Karma 0.11
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.
1 parent 9b78280 commit 89c9817

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lib/reporter.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,18 @@ var CoverageReporter = function(rootConfig, helper, logger) {
6464
}
6565

6666
this.onRunStart = function(browsers) {
67-
collectors = {};
68-
browsers.forEach(function(browser) {
69-
collectors[browser.id] = new istanbul.Collector();
70-
});
67+
collectors = Object.create(null);
68+
69+
// TODO(vojta): remove once we don't care about Karma 0.10
70+
if (browsers) {
71+
browsers.forEach(function(browser) {
72+
collectors[browser.id] = new istanbul.Collector();
73+
});
74+
}
75+
};
76+
77+
this.onBrowserStart = function(browser) {
78+
collectors[browser.id] = new istanbul.Collector();
7179
};
7280

7381
this.onBrowserComplete = function(browser, result) {

test/reporter.spec.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ describe 'reporter', ->
120120
fakeOpera = makeBrowser 'bbb', 'Opera/9.80 Mac OS X Version/12.00', browsers, emitter
121121
browsers.add fakeChrome
122122
browsers.add fakeOpera
123-
reporter.onRunStart browsers
123+
reporter.onRunStart()
124+
browsers.forEach (b) -> reporter.onBrowserStart b
124125
mockFs.writeFile.reset()
125126
mockMkdir.reset()
126127

0 commit comments

Comments
 (0)