Skip to content

Commit

Permalink
Merge branch 'fix_configurereporter' of https://github.com/tomv564/ja…
Browse files Browse the repository at this point in the history
…smine-npm into tomv564-fix_configurereporter

- Merges #100 from @tomv564
- Fixes #95
  • Loading branch information
Gregg Van Hove committed Dec 1, 2016
2 parents 3447885 + 0a9cace commit e0d502f
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 e0d502f

Please sign in to comment.