Skip to content

Commit

Permalink
Merge pull request #56 from bcaudan/successes-summary
Browse files Browse the repository at this point in the history
Adds successes summary,  resolves #49
  • Loading branch information
bcaudan authored Aug 19, 2016
2 parents 92dedc5 + 1cfe273 commit 2a5ad1c
Show file tree
Hide file tree
Showing 5 changed files with 53 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: false,
displaySuccessfulSpec: true,
displayFailedSpec: true,
displayPendingSpec: true,
Expand Down
9 changes: 9 additions & 0 deletions spec/default-display.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ describe 'with default display', ->
.contains 'Executed 1 of 1 spec SUCCESS in {time}.'


it 'should not report successes summary', ->
expect(new Test(@reporter, ->
@describe 'suite', =>
@it 'spec', =>
@passed()
).summary)
.not.contains /Successes/


it 'should report failure', ->
expect(new Test(@reporter, ->
@describe 'suite', =>
Expand Down
11 changes: 11 additions & 0 deletions spec/display-successes-summary.spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe 'with successes summary enabled', ->
beforeEach ->
@reporter = new SpecReporter(displaySuccessesSummary: true)

describe 'when summary', ->
it 'should report successes summary', ->
expect(new Test(@reporter, ->
@describe 'suite 1', =>
@it 'spec 1', =>
@passed()
).summary).contains /Successes/
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 @@ -52,6 +57,23 @@ SpecDisplay.prototype = {
}
},

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 @@ -103,6 +125,7 @@ SpecDisplay.prototype = {
},

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

0 comments on commit 2a5ad1c

Please sign in to comment.