-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves exit code reporting and defining an onComplete callback to an E…
…xitCodeReporter - Deprecates passing an onComplete to ConsoleReporter and as an option to configureDefaultReporter - Adds an exit code reporter right before test execution - Adds jasmine.onComplete that defines a callback for the exit code reporter to call
- Loading branch information
Christopher Amavisca and Gregg Van Hove
committed
Feb 6, 2015
1 parent
92f47d3
commit 9cdc067
Showing
7 changed files
with
183 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = function() { | ||
var results = true; | ||
var onCompleteCallback = function() {}; | ||
|
||
this.onComplete = function(callback) { | ||
onCompleteCallback = callback; | ||
}; | ||
|
||
this.jasmineDone = function() { | ||
onCompleteCallback(results); | ||
}; | ||
|
||
this.specDone = function(result) { | ||
if(result.status === 'failed') { | ||
results = false; | ||
} | ||
}; | ||
|
||
this.suiteDone = function(result) { | ||
if (result.failedExpectations && result.failedExpectations.length > 0) { | ||
results = false; | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
describe('ExitCodeReporter', function() { | ||
var ExitCodeReporter = require('../lib/exit_code_reporter'); | ||
var reporter, onComplete; | ||
|
||
beforeEach(function() { | ||
reporter = new ExitCodeReporter(); | ||
onComplete = jasmine.createSpy('onComplete'); | ||
reporter.onComplete(onComplete); | ||
}); | ||
|
||
it('should report success with no specs', function() { | ||
reporter.jasmineDone(); | ||
|
||
expect(onComplete).toHaveBeenCalledWith(true); | ||
}); | ||
|
||
it('should report success with all successful specs', function() { | ||
reporter.specDone({status: 'passed'}); | ||
reporter.specDone({status: 'pending'}); | ||
|
||
reporter.jasmineDone(); | ||
|
||
expect(onComplete).toHaveBeenCalledWith(true); | ||
}); | ||
|
||
it('should report failure with any failing specs', function() { | ||
reporter.specDone({status: 'passed'}); | ||
reporter.specDone({status: 'pending'}); | ||
reporter.specDone({status: 'failed'}); | ||
|
||
reporter.jasmineDone(); | ||
|
||
expect(onComplete).toHaveBeenCalledWith(false); | ||
}); | ||
|
||
it('should report success with all passing suites', function() { | ||
reporter.suiteDone({failedExpectations: []}); | ||
reporter.suiteDone({}); | ||
|
||
reporter.jasmineDone(); | ||
|
||
expect(onComplete).toHaveBeenCalledWith(true); | ||
}); | ||
|
||
it('should report failure with any failing suites', function() { | ||
reporter.suiteDone({failedExpectations: [{"some": 'stuff'}]}); | ||
|
||
reporter.jasmineDone(); | ||
|
||
expect(onComplete).toHaveBeenCalledWith(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters