diff --git a/README.md b/README.md index b9dad059..ae4b4482 100644 --- a/README.md +++ b/README.md @@ -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', diff --git a/example/run-example.js b/example/run-example.js index b2e7b197..6396eb55 100644 --- a/example/run-example.js +++ b/example/run-example.js @@ -10,6 +10,7 @@ jasmine.getEnv().addReporter(new SpecReporter({ displayStacktrace: 'none', displayFailuresSummary: true, displayPendingSummary: true, + displaySuccessesSummary: false, displaySuccessfulSpec: true, displayFailedSpec: true, displayPendingSpec: true, diff --git a/spec/default-display.spec.coffee b/spec/default-display.spec.coffee index 8a9b3da2..ff61ba35 100644 --- a/spec/default-display.spec.coffee +++ b/spec/default-display.spec.coffee @@ -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', => diff --git a/spec/display-successes-summary.spec.coffee b/spec/display-successes-summary.spec.coffee new file mode 100644 index 00000000..ee9561e8 --- /dev/null +++ b/spec/display-successes-summary.spec.coffee @@ -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/ diff --git a/src/spec-display.js b/src/spec-display.js index be1a769b..9cf8f243 100644 --- a/src/spec-display.js +++ b/src/spec-display.js @@ -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; @@ -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(); } @@ -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 *"); @@ -103,6 +125,7 @@ SpecDisplay.prototype = { }, successful: function (spec) { + this.successfulSpecs.push(spec); if (this.displaySuccessfulSpec) { this.ensureSuiteDisplayed(); var log = null;