diff --git a/lib/jasmine-core/jasmine-html.js b/lib/jasmine-core/jasmine-html.js
index 97b83b2f..6a871546 100644
--- a/lib/jasmine-core/jasmine-html.js
+++ b/lib/jasmine-core/jasmine-html.js
@@ -242,18 +242,19 @@ jasmineRequire.HtmlReporter = function(j$) {
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage, seedBar));
var errorBarClassName = 'jasmine-bar jasmine-errored';
- var errorBarMessagePrefix = 'AfterAll ';
+ var afterAllMessagePrefix = 'AfterAll ';
for(var i = 0; i < failedSuites.length; i++) {
var failedSuite = failedSuites[i];
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
- alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failedSuite.failedExpectations[j].message));
+ alert.appendChild(createDom('span', {className: errorBarClassName}, afterAllMessagePrefix + failedSuite.failedExpectations[j].message));
}
}
for(i = 0; i < globalFailures.length; i++) {
var failure = globalFailures[i];
- alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failure.message));
+ var prefix = failure.globalErrorType === 'load' ? 'Error during loading: ' : afterAllMessagePrefix;
+ alert.appendChild(createDom('span', {className: errorBarClassName}, prefix + failure.message));
}
var results = find('.jasmine-results');
diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js
index 023efe24..a0a4b525 100644
--- a/lib/jasmine-core/jasmine.js
+++ b/lib/jasmine-core/jasmine.js
@@ -778,6 +778,7 @@ getJasmineRequireObj().Env = function(j$) {
if (!suppressLoadErrors) {
topSuite.result.failedExpectations.push({
passed: false,
+ globalErrorType: 'load',
message: message
});
}
@@ -5177,7 +5178,13 @@ getJasmineRequireObj().Suite = function(j$) {
actual: '',
error: arguments[0]
};
- this.result.failedExpectations.push(this.expectationResultFactory(data));
+ var failedExpectation = this.expectationResultFactory(data);
+
+ if (!this.parentSuite) {
+ failedExpectation.globalErrorType = 'afterAll';
+ }
+
+ this.result.failedExpectations.push(failedExpectation);
} else {
for (var i = 0; i < this.children.length; i++) {
var child = this.children[i];
diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js
index df737be8..50b249f5 100644
--- a/spec/core/integration/EnvSpec.js
+++ b/spec/core/integration/EnvSpec.js
@@ -422,6 +422,49 @@ describe("Env integration", function() {
env.execute();
});
+ it("tags top-level afterAll failures with a type", function(done) {
+ var env = new jasmineUnderTest.Env();
+
+ env.addReporter({jasmineDone: function(result) {
+ expect(result.failedExpectations[0].globalErrorType).toEqual('afterAll');
+ done();
+ }});
+
+ env.it('has a spec', function() {});
+
+ env.afterAll(function() {
+ debugger;
+ throw 'nope';
+ });
+
+ env.execute();
+ });
+
+ it("does not tag suite afterAll failures with a type", function(done) {
+ var env = new jasmineUnderTest.Env(),
+ reporter = {
+ jasmineDone: function() {
+ expect(reporter.suiteDone).toHaveBeenCalled();
+ done();
+ },
+ suiteDone: jasmine.createSpy('suiteDone').and.callFake(function(result) {
+ expect(result.failedExpectations[0].globalErrorType).toBeFalsy();
+ })
+ }
+
+ env.addReporter(reporter);
+
+ env.describe('a suite', function() {
+ env.it('has a spec', function() {});
+
+ env.afterAll(function() {
+ throw 'nope';
+ });
+ });
+
+ env.execute();
+ });
+
it("fails all underlying specs when the beforeAll fails", function (done) {
var env = new jasmineUnderTest.Env(),
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
@@ -1991,10 +2034,12 @@ describe("Env integration", function() {
expect(e.failedExpectations).toEqual([
{
passed: false,
+ globalErrorType: 'load',
message: 'Uncaught SyntaxError: Unexpected end of input'
},
{
passed: false,
+ globalErrorType: 'load',
message: 'Uncaught Error: ENOCHEESE'
}
]);
diff --git a/spec/html/HtmlReporterSpec.js b/spec/html/HtmlReporterSpec.js
index 10f04fa5..b88cafa7 100644
--- a/spec/html/HtmlReporterSpec.js
+++ b/spec/html/HtmlReporterSpec.js
@@ -195,16 +195,23 @@ describe("HtmlReporter", function() {
reporter.jasmineStarted({});
reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My After All Exception' }] });
reporter.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My Other Exception' }] });
- reporter.jasmineDone({ failedExpectations: [{ message: 'Global After All Failure' }, { message: 'Other Global' }] });
+ reporter.jasmineDone({ failedExpectations: [
+ { message: 'Global After All Failure', globalErrorType: 'afterAll' },
+ { message: 'Other Global' },
+ { message: 'Your JS is borken', globalErrorType: 'load' }
+ ] });
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
- expect(alertBars.length).toEqual(5);
+ expect(alertBars.length).toEqual(6);
expect(alertBars[1].innerHTML).toMatch(/My After All Exception/);
expect(alertBars[1].getAttribute("class")).toEqual('jasmine-bar jasmine-errored');
expect(alertBars[2].innerHTML).toMatch(/My Other Exception/);
- expect(alertBars[3].innerHTML).toMatch(/Global After All Failure/);
+ expect(alertBars[3].innerHTML).toMatch(/AfterAll Global After All Failure/);
+ // TODO: What about this?
expect(alertBars[4].innerHTML).toMatch(/Other Global/);
+
+ expect(alertBars[5].innerHTML).toMatch(/Error during loading: Your JS is borken/);
});
});
diff --git a/src/core/Env.js b/src/core/Env.js
index d13fdbb6..4875623f 100644
--- a/src/core/Env.js
+++ b/src/core/Env.js
@@ -97,6 +97,7 @@ getJasmineRequireObj().Env = function(j$) {
if (!suppressLoadErrors) {
topSuite.result.failedExpectations.push({
passed: false,
+ globalErrorType: 'load',
message: message
});
}
diff --git a/src/core/Suite.js b/src/core/Suite.js
index e85ab04e..ed7ed3fb 100644
--- a/src/core/Suite.js
+++ b/src/core/Suite.js
@@ -119,7 +119,13 @@ getJasmineRequireObj().Suite = function(j$) {
actual: '',
error: arguments[0]
};
- this.result.failedExpectations.push(this.expectationResultFactory(data));
+ var failedExpectation = this.expectationResultFactory(data);
+
+ if (!this.parentSuite) {
+ failedExpectation.globalErrorType = 'afterAll';
+ }
+
+ this.result.failedExpectations.push(failedExpectation);
} else {
for (var i = 0; i < this.children.length; i++) {
var child = this.children[i];
diff --git a/src/html/HtmlReporter.js b/src/html/HtmlReporter.js
index 8ae8998c..da5b7df2 100644
--- a/src/html/HtmlReporter.js
+++ b/src/html/HtmlReporter.js
@@ -213,18 +213,19 @@ jasmineRequire.HtmlReporter = function(j$) {
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage, seedBar));
var errorBarClassName = 'jasmine-bar jasmine-errored';
- var errorBarMessagePrefix = 'AfterAll ';
+ var afterAllMessagePrefix = 'AfterAll ';
for(var i = 0; i < failedSuites.length; i++) {
var failedSuite = failedSuites[i];
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
- alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failedSuite.failedExpectations[j].message));
+ alert.appendChild(createDom('span', {className: errorBarClassName}, afterAllMessagePrefix + failedSuite.failedExpectations[j].message));
}
}
for(i = 0; i < globalFailures.length; i++) {
var failure = globalFailures[i];
- alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failure.message));
+ var prefix = failure.globalErrorType === 'load' ? 'Error during loading: ' : afterAllMessagePrefix;
+ alert.appendChild(createDom('span', {className: errorBarClassName}, prefix + failure.message));
}
var results = find('.jasmine-results');