From eefa71653032e0cbc982e7283c630673279c9600 Mon Sep 17 00:00:00 2001 From: slackersoft Date: Fri, 26 Sep 2014 09:12:48 -0700 Subject: [PATCH] set suite status to failed when afterAll has failures --- spec/core/SuiteSpec.js | 10 ++++++++++ spec/html/HtmlReporterSpec.js | 4 ++-- src/core/Suite.js | 15 +++++++++++++-- src/html/HtmlReporter.js | 2 +- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index 93b5ec33..c84afb8e 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -301,4 +301,14 @@ describe("Suite", function() { failedExpectations: [] }); }); + + it('has a status of failed if any afterAll expectations have failed', function() { + var suite = new j$.Suite({ + expectationResultFactory: function() { return 'hi'; } + }); + suite.addChild({ result: { status: 'done' } }); + + suite.addExpectationResult(false); + expect(suite.status()).toBe('failed'); + }); }); diff --git a/spec/html/HtmlReporterSpec.js b/spec/html/HtmlReporterSpec.js index 8c952e6a..7cb2bfd8 100644 --- a/spec/html/HtmlReporterSpec.js +++ b/spec/html/HtmlReporterSpec.js @@ -194,8 +194,8 @@ describe("New HtmlReporter", function() { reporter.initialize(); reporter.jasmineStarted({}); - reporter.suiteDone({ failedExpectations: [{ message: 'My After All Exception' }] }); - reporter.suiteDone({ failedExpectations: [{ message: 'My Other Exception' }] }); + reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My After All Exception' }] }); + reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My Other Exception' }] }); reporter.jasmineDone({}); var alertBars = container.querySelectorAll(".alert .bar"); diff --git a/src/core/Suite.js b/src/core/Suite.js index 4b2642a2..99e81d8f 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -43,7 +43,6 @@ getJasmineRequireObj().Suite = function() { Suite.prototype.disable = function() { this.disabled = true; - this.result.status = 'disabled'; }; Suite.prototype.beforeEach = function(fn) { @@ -66,6 +65,18 @@ getJasmineRequireObj().Suite = function() { this.children.push(child); }; + Suite.prototype.status = function() { + if (this.disabled) { + return 'disabled'; + } + + if (this.result.failedExpectations.length > 0) { + return 'failed'; + } else { + return 'finished'; + } + }; + Suite.prototype.execute = function(onComplete) { var self = this; @@ -96,7 +107,7 @@ getJasmineRequireObj().Suite = function() { }); function complete() { - self.result.status = self.disabled ? 'disabled' : 'finished'; + self.result.status = self.status(); self.resultCallback(self.result); if (onComplete) { diff --git a/src/html/HtmlReporter.js b/src/html/HtmlReporter.js index a5ff9960..dc91d7f0 100644 --- a/src/html/HtmlReporter.js +++ b/src/html/HtmlReporter.js @@ -55,7 +55,7 @@ jasmineRequire.HtmlReporter = function(j$) { }; this.suiteDone = function(result) { - if (result.failedExpectations && result.failedExpectations.length > 0) { + if (result.status == 'failed') { failedSuites.push(result); }