Skip to content

Commit 31897dd

Browse files
author
Gregg Van Hove
authored
Merge pull request #89 from flore77/master
Only use the default exiting if the default reporter is used
2 parents 164b799 + b416b5c commit 31897dd

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

lib/jasmine.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function Jasmine(options) {
1818
this.specFiles = [];
1919
this.helperFiles = [];
2020
this.env = this.jasmine.getEnv();
21+
this.reportersCount = 0;
2122
this.exitCodeReporter = new ExitCodeReporter();
2223
this.onCompleteCallbackAdded = false;
2324
this.exit = exit;
@@ -46,6 +47,7 @@ Jasmine.prototype.addSpecFile = function(filePath) {
4647

4748
Jasmine.prototype.addReporter = function(reporter) {
4849
this.env.addReporter(reporter);
50+
this.reportersCount++;
4951
};
5052

5153
Jasmine.prototype.provideFallbackReporter = function(reporter) {
@@ -65,7 +67,7 @@ Jasmine.prototype.configureDefaultReporter = function(options) {
6567
}
6668
var consoleReporter = new module.exports.ConsoleReporter(options);
6769
this.provideFallbackReporter(consoleReporter);
68-
this.defaultReporterAdded = true;
70+
this.defaultReporterAdded = this.reportersCount === 0;
6971
};
7072

7173
Jasmine.prototype.addMatchers = function(matchers) {

spec/jasmine_spec.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,24 @@ describe('Jasmine', function() {
8585
expect(this.testJasmine.env.provideFallbackReporter).toHaveBeenCalledWith({someProperty: 'some value'});
8686
});
8787

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

91-
this.testJasmine.configureDefaultReporter(reporterOptions);
92+
this.testJasmine.configureDefaultReporter(reporterOptions);
93+
94+
expect(this.testJasmine.defaultReporterAdded).toBe(true);
95+
});
9296

93-
expect(this.testJasmine.defaultReporterAdded).toBe(true);
97+
it('to false if the default reporter is not used', function() {
98+
var reporterOptions = {};
99+
var dummyReporter = {};
100+
101+
this.testJasmine.addReporter(dummyReporter);
102+
this.testJasmine.configureDefaultReporter(reporterOptions);
103+
104+
expect(this.testJasmine.defaultReporterAdded).toBe(false);
105+
});
94106
});
95107

96108
describe('passing in an onComplete function', function() {

0 commit comments

Comments
 (0)