Skip to content

Commit

Permalink
Adds successes summary, resolves bcaudan#49
Browse files Browse the repository at this point in the history
Signed-off-by: Bebe Peng <[email protected]>
  • Loading branch information
herbert-pivotal authored and bebepeng committed May 4, 2016
1 parent a5b5bee commit 2b7687a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ You can customize the output of the reporter yourself: [see how](docs/customize-

```js
{
displayStacktrace: 'none', // display stacktrace for each failed assertion, values: (all|specs|summary|none)
displayFailuresSummary: true, // display summary of all failures after execution
displayPendingSummary: true, // display summary of all pending specs after execution
displaySuccessfulSpec: true, // display each successful spec
displayFailedSpec: true, // display each failed spec
displayPendingSpec: false, // display each pending spec
displaySpecDuration: false, // display each spec duration
displaySuiteNumber: false, // display each suite number (hierarchical)
displayStacktrace: 'none', // display stacktrace for each failed assertion, values: (all|specs|summary|none)
displaySuccessesSummary: false, // display summary of all successes after execution
displayFailuresSummary: true, // display summary of all failures after execution
displayPendingSummary: true, // display summary of all pending specs after execution
displaySuccessfulSpec: true, // display each successful spec
displayFailedSpec: true, // display each failed spec
displayPendingSpec: false, // display each pending spec
displaySpecDuration: false, // display each spec duration
displaySuiteNumber: false, // display each suite number (hierarchical)
colors: {
success: 'green',
failure: 'red',
Expand Down
1 change: 1 addition & 0 deletions example/run-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jasmine.getEnv().addReporter(new SpecReporter({
displayStacktrace: 'none',
displayFailuresSummary: true,
displayPendingSummary: true,
displaySuccessesSummary: true,
displaySuccessfulSpec: true,
displayFailedSpec: true,
displayPendingSpec: true,
Expand Down
23 changes: 23 additions & 0 deletions src/spec-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ var SpecDisplay = function (options, displayProcessors) {
this.currentIndent = '';
this.suiteHierarchy = [];
this.suiteHierarchyDisplayed = [];
this.successfulSpecs = [];
this.failedSpecs = [];
this.pendingSpecs = [];
this.lastWasNewLine = false;
this.displaySuccessesSummary = options.displaySuccessesSummary || false;
this.displayFailuresSummary = options.displayFailuresSummary !== false;
this.displayPendingSummary = options.displayPendingSummary !== false;
this.displaySuccessfulSpec = options.displaySuccessfulSpec !== false;
Expand Down Expand Up @@ -39,6 +41,9 @@ SpecDisplay.prototype = {

this.resetIndent();
this.newLine();
if (this.displaySuccessesSummary && metrics.successfulSpecs > 0) {
this.successesSummary();
}
if (this.displayFailuresSummary && metrics.failedSpecs > 0) {
this.failuresSummary();
}
Expand All @@ -48,6 +53,23 @@ SpecDisplay.prototype = {
this.log(execution + successful.success + failed.failure + pending.pending + skipped + duration);
},

successesSummary: function () {
this.log("**************************************************");
this.log("* Successes *");
this.log("**************************************************");
this.newLine();
for (var i = 0 ; i < this.successfulSpecs.length ; i++) {
this.successfulSummary(this.successfulSpecs[i], i + 1);
this.newLine();
}
this.newLine();
this.resetIndent();
},

successfulSummary: function (spec, index) {
this.log(index + ') ' + spec.fullName);
},

failuresSummary: function () {
this.log("**************************************************");
this.log("* Failures *");
Expand Down Expand Up @@ -99,6 +121,7 @@ SpecDisplay.prototype = {
},

successful: function (spec) {
this.successfulSpecs.push(spec);
if (this.displaySuccessfulSpec) {
this.ensureSuiteDisplayed();
var log = null;
Expand Down

0 comments on commit 2b7687a

Please sign in to comment.