Skip to content

Commit

Permalink
Only use the default exiting if the default reporter is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
flore77 committed Sep 1, 2016
1 parent 164b799 commit 723779f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function Jasmine(options) {
this.specFiles = [];
this.helperFiles = [];
this.env = this.jasmine.getEnv();
this.reportersCount = 0;
this.exitCodeReporter = new ExitCodeReporter();
this.onCompleteCallbackAdded = false;
this.exit = exit;
Expand Down Expand Up @@ -46,6 +47,7 @@ Jasmine.prototype.addSpecFile = function(filePath) {

Jasmine.prototype.addReporter = function(reporter) {
this.env.addReporter(reporter);
this.reportersCount++;
};

Jasmine.prototype.provideFallbackReporter = function(reporter) {
Expand All @@ -65,7 +67,7 @@ Jasmine.prototype.configureDefaultReporter = function(options) {
}
var consoleReporter = new module.exports.ConsoleReporter(options);
this.provideFallbackReporter(consoleReporter);
this.defaultReporterAdded = true;
this.defaultReporterAdded = this.reportersCount === 0 ? true : false;
};

Jasmine.prototype.addMatchers = function(matchers) {
Expand Down
20 changes: 16 additions & 4 deletions spec/jasmine_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,24 @@ describe('Jasmine', function() {
expect(this.testJasmine.env.provideFallbackReporter).toHaveBeenCalledWith({someProperty: 'some value'});
});

it('sets the defaultReporterAdded flag', function() {
var reporterOptions = {};
describe('sets the defaultReportedAdded flag', function() {
it('to true if the default reporter is used', function() {
var reporterOptions = {};

this.testJasmine.configureDefaultReporter(reporterOptions);
this.testJasmine.configureDefaultReporter(reporterOptions);

expect(this.testJasmine.defaultReporterAdded).toBe(true);
});

expect(this.testJasmine.defaultReporterAdded).toBe(true);
it('to false if the default reporter is not used', function() {
var reporterOptions = {};
var dummyReporter = {};

this.testJasmine.addReporter(dummyReporter);
this.testJasmine.configureDefaultReporter(reporterOptions);

expect(this.testJasmine.defaultReporterAdded).toBe(false);
});
});

describe('passing in an onComplete function', function() {
Expand Down

0 comments on commit 723779f

Please sign in to comment.