From 3a5672cd3340bde5d44d17a86e34e4ad2440ef14 Mon Sep 17 00:00:00 2001 From: "Christopher Amavisca, Greg Cobb and Luan Santos" Date: Mon, 10 Mar 2014 12:00:49 -0700 Subject: [PATCH] Show message if no specs are found in console reporter [#12784235] --- lib/console/console.js | 19 ++++++++++++------- spec/console/ConsoleReporterSpec.js | 12 ++++++++++++ src/console/ConsoleReporter.js | 19 ++++++++++++------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/lib/console/console.js b/lib/console/console.js index 97821451..c54f72da 100644 --- a/lib/console/console.js +++ b/lib/console/console.js @@ -71,16 +71,21 @@ getJasmineRequireObj().ConsoleReporter = function() { specFailureDetails(failedSpecs[i]); } - printNewline(); - var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' + - failureCount + ' ' + plural('failure', failureCount); + if(specCount > 0) { + printNewline(); - if (pendingCount) { - specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount); + var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' + + failureCount + ' ' + plural('failure', failureCount); + + if (pendingCount) { + specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount); + } + + print(specCounts); + } else { + print('No specs found'); } - print(specCounts); - printNewline(); var seconds = timer.elapsed() / 1000; print('Finished in ' + seconds + ' ' + plural('second', seconds)); diff --git a/spec/console/ConsoleReporterSpec.js b/spec/console/ConsoleReporterSpec.js index 2a0e927b..0957039b 100644 --- a/spec/console/ConsoleReporterSpec.js +++ b/spec/console/ConsoleReporterSpec.js @@ -80,6 +80,18 @@ describe("ConsoleReporter", function() { expect(out.getOutput()).toEqual("*"); }); + it("alerts user if there are no specs", function(){ + var reporter = new j$.ConsoleReporter({ + print: out.print + }); + + reporter.jasmineStarted(); + out.clear(); + reporter.jasmineDone(); + + expect(out.getOutput()).toMatch(/No specs found/); + }); + it("reports a summary when done (singular spec and time)", function() { var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), reporter = new j$.ConsoleReporter({ diff --git a/src/console/ConsoleReporter.js b/src/console/ConsoleReporter.js index f2fac6b8..426c431f 100644 --- a/src/console/ConsoleReporter.js +++ b/src/console/ConsoleReporter.js @@ -36,16 +36,21 @@ getJasmineRequireObj().ConsoleReporter = function() { specFailureDetails(failedSpecs[i]); } - printNewline(); - var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' + - failureCount + ' ' + plural('failure', failureCount); + if(specCount > 0) { + printNewline(); - if (pendingCount) { - specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount); + var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' + + failureCount + ' ' + plural('failure', failureCount); + + if (pendingCount) { + specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount); + } + + print(specCounts); + } else { + print('No specs found'); } - print(specCounts); - printNewline(); var seconds = timer.elapsed() / 1000; print('Finished in ' + seconds + ' ' + plural('second', seconds));