From 5666a0c9d0f09893b88512adb467e00eb3bf3a87 Mon Sep 17 00:00:00 2001 From: Mauricio Silva Date: Fri, 19 Feb 2016 14:30:30 -0200 Subject: [PATCH] Adds checking to avoid issues when fallback reporter is unavailable --- lib/jasmine.js | 8 ++++++-- spec/jasmine_spec.js | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/jasmine.js b/lib/jasmine.js index 9013058a..206c72e3 100644 --- a/lib/jasmine.js +++ b/lib/jasmine.js @@ -45,7 +45,12 @@ Jasmine.prototype.addReporter = function(reporter) { }; Jasmine.prototype.provideFallbackReporter = function(reporter) { - this.env.provideFallbackReporter(reporter); + var reportHandler = this.env.addReporter; + if (this.env.provideFallbackReporter) { + reportHandler = this.env.provideFallbackReporter; + } + reportHandler(reporter); + this.defaultReporterAdded = true; }; Jasmine.prototype.configureDefaultReporter = function(options) { @@ -61,7 +66,6 @@ Jasmine.prototype.configureDefaultReporter = function(options) { } var consoleReporter = new module.exports.ConsoleReporter(options); this.provideFallbackReporter(consoleReporter); - this.defaultReporterAdded = true; }; Jasmine.prototype.addMatchers = function(matchers) { diff --git a/spec/jasmine_spec.js b/spec/jasmine_spec.js index 6217dcb1..a070ac1d 100644 --- a/spec/jasmine_spec.js +++ b/spec/jasmine_spec.js @@ -253,7 +253,6 @@ describe('Jasmine', function() { it('adds a default reporter as a fallback reporter', function() { this.testJasmine.addReporter(new Jasmine.ConsoleReporter({})); - //spyOn(this.testJasmine, 'configureDefaultReporter'); spyOn(this.testJasmine, 'loadSpecs'); this.testJasmine.execute();