Skip to content

Commit

Permalink
don't call configureDefaultReporter in execute if it was already called
Browse files Browse the repository at this point in the history
  • Loading branch information
tomv564 committed Nov 13, 2016
1 parent 6f58487 commit 0a9cace
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function Jasmine(options) {
this.showingColors = true;
this.reporter = new module.exports.ConsoleReporter();
this.env.addReporter(this.reporter);
this.defaultReporterConfigured = false;

var jasmineRunner = this;
this.completionReporter.onComplete(function(passed) {
Expand Down Expand Up @@ -74,6 +75,7 @@ Jasmine.prototype.configureDefaultReporter = function(options) {
this.printDeprecation('Passing in an onComplete function to configureDefaultReporter is deprecated.');
}
this.reporter.setOptions(options);
this.defaultReporterConfigured = true;
};

Jasmine.prototype.addMatchers = function(matchers) {
Expand Down Expand Up @@ -157,7 +159,9 @@ Jasmine.prototype.exitCodeCompletion = function(passed) {

Jasmine.prototype.execute = function(files, filterString) {
this.loadHelpers();
this.configureDefaultReporter({ showColors: this.showingColors });
if (!this.defaultReporterConfigured) {
this.configureDefaultReporter({ showColors: this.showingColors });
}

if(filterString) {
var specFilter = new ConsoleSpecFilter({
Expand Down
14 changes: 14 additions & 0 deletions spec/jasmine_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,20 @@ describe('Jasmine', function() {
expect(this.testJasmine.env.execute).toHaveBeenCalled();
});

it('does not configure the default reporter if this was already done', function() {
spyOn(this.testJasmine, 'loadSpecs');

this.testJasmine.configureDefaultReporter({showColors: false});

spyOn(this.testJasmine, 'configureDefaultReporter');

this.testJasmine.execute();

expect(this.testJasmine.configureDefaultReporter).not.toHaveBeenCalled();
expect(this.testJasmine.loadSpecs).toHaveBeenCalled();
expect(this.testJasmine.env.execute).toHaveBeenCalled();
});

it('loads helper files before checking if any reporters were added', function() {
var loadHelpers = spyOn(this.testJasmine, 'loadHelpers');
spyOn(this.testJasmine, 'configureDefaultReporter').and.callFake(function() {
Expand Down

0 comments on commit 0a9cace

Please sign in to comment.