diff --git a/lib/jasmine-core/jasmine-html.js b/lib/jasmine-core/jasmine-html.js
index 51f79786..ba3fb447 100644
--- a/lib/jasmine-core/jasmine-html.js
+++ b/lib/jasmine-core/jasmine-html.js
@@ -303,8 +303,10 @@ jasmineRequire.HtmlReporter = function(j$) {
} else {
return prefix;
}
- } else {
+ } else if (failure.globalErrorType === 'afterAll') {
return afterAllMessagePrefix + failure.message;
+ } else {
+ return failure.message;
}
}
diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js
index 600302b8..d4badddb 100644
--- a/lib/jasmine-core/jasmine.js
+++ b/lib/jasmine-core/jasmine.js
@@ -1331,15 +1331,15 @@ getJasmineRequireObj().Env = function(j$) {
};
function recordLateError(error) {
- topSuite.result.failedExpectations.push(
- expectationResultFactory({
- error,
- passed: false,
- matcherName: '',
- expected: '',
- actual: ''
- })
- );
+ const result = expectationResultFactory({
+ error,
+ passed: false,
+ matcherName: '',
+ expected: '',
+ actual: ''
+ });
+ result.globalErrorType = 'lateError';
+ topSuite.result.failedExpectations.push(result);
}
function recordLateExpectation(runable, runableType, result) {
@@ -3912,6 +3912,9 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
* @property {Boolean} passed - Whether the expectation passed or failed.
* @property {Object} expected - If the expectation failed, what was the expected value.
* @property {Object} actual - If the expectation failed, what actual value was produced.
+ * @property {String|undefined} globalErrorType - The type of an error that
+ * is reported on the top suite. Valid values are undefined, "afterAll",
+ * "load", "lateExpectation", and "lateError".
*/
var result = {
matcherName: options.matcherName,
diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js
index fdac97f7..f712ec2a 100644
--- a/spec/core/integration/EnvSpec.js
+++ b/spec/core/integration/EnvSpec.js
@@ -534,9 +534,11 @@ describe('Env integration', function() {
expect(errors[0].message)
.withContext('top beforeAll')
.toContain(message);
+ expect(errors[0].globalErrorType).toEqual('lateError');
expect(errors[1].message)
.withContext('top afterAll')
.toContain(message);
+ expect(errors[1].globalErrorType).toEqual('lateError');
done();
});
});
@@ -568,9 +570,11 @@ describe('Env integration', function() {
expect(errors[0].message)
.withContext('suite beforeAll')
.toContain(message);
+ expect(errors[0].globalErrorType).toEqual('lateError');
expect(errors[1].message)
.withContext('suite afterAll')
.toContain(message);
+ expect(errors[1].globalErrorType).toEqual('lateError');
done();
});
});
@@ -605,12 +609,15 @@ describe('Env integration', function() {
expect(errors[0].message)
.withContext('error caused by beforeEach')
.toContain(message);
+ expect(errors[0].globalErrorType).toEqual('lateError');
expect(errors[1].message)
.withContext('error caused by it')
.toContain(message);
+ expect(errors[1].globalErrorType).toEqual('lateError');
expect(errors[2].message)
.withContext('error caused by afterEach')
.toContain(message);
+ expect(errors[2].globalErrorType).toEqual('lateError');
done();
});
});
@@ -634,6 +641,7 @@ describe('Env integration', function() {
.failedExpectations;
expect(errors.length).toEqual(1);
expect(errors[0].message).toContain(message);
+ expect(errors[0].globalErrorType).toEqual('lateError');
done();
});
});
diff --git a/spec/html/HtmlReporterSpec.js b/spec/html/HtmlReporterSpec.js
index a79e9cef..b99751bc 100644
--- a/spec/html/HtmlReporterSpec.js
+++ b/spec/html/HtmlReporterSpec.js
@@ -704,6 +704,50 @@ describe('HtmlReporter', function() {
expect(alertBars[2].innerHTML).not.toMatch(/line/);
});
+ it('does not display the "AfterAll" prefix for other error types', function() {
+ const container = document.createElement('div');
+ const getContainer = function() {
+ return container;
+ };
+ const reporter = new jasmineUnderTest.HtmlReporter({
+ env: env,
+ getContainer: getContainer,
+ createElement: function() {
+ return document.createElement.apply(document, arguments);
+ },
+ createTextNode: function() {
+ return document.createTextNode.apply(document, arguments);
+ }
+ });
+
+ reporter.initialize();
+
+ reporter.jasmineStarted({});
+ reporter.jasmineDone({
+ failedExpectations: [
+ { message: 'load error', globalErrorType: 'load' },
+ {
+ message: 'lateExpectation error',
+ globalErrorType: 'lateExpectation'
+ },
+ { message: 'lateError error', globalErrorType: 'lateError' }
+ ]
+ });
+
+ const alertBars = container.querySelectorAll(
+ '.jasmine-alert .jasmine-bar'
+ );
+
+ expect(alertBars.length).toEqual(4);
+ expect(alertBars[1].textContent).toContain('load error');
+ expect(alertBars[2].textContent).toContain('lateExpectation error');
+ expect(alertBars[3].textContent).toContain('lateError error');
+
+ for (let bar of alertBars) {
+ expect(bar.textContent).not.toContain('AfterAll');
+ }
+ });
+
it('displays file and line information if available', function() {
var container = document.createElement('div'),
getContainer = function() {
diff --git a/src/core/Env.js b/src/core/Env.js
index 49c6735a..be59c1e7 100644
--- a/src/core/Env.js
+++ b/src/core/Env.js
@@ -339,15 +339,15 @@ getJasmineRequireObj().Env = function(j$) {
};
function recordLateError(error) {
- topSuite.result.failedExpectations.push(
- expectationResultFactory({
- error,
- passed: false,
- matcherName: '',
- expected: '',
- actual: ''
- })
- );
+ const result = expectationResultFactory({
+ error,
+ passed: false,
+ matcherName: '',
+ expected: '',
+ actual: ''
+ });
+ result.globalErrorType = 'lateError';
+ topSuite.result.failedExpectations.push(result);
}
function recordLateExpectation(runable, runableType, result) {
diff --git a/src/core/ExpectationResult.js b/src/core/ExpectationResult.js
index d3ea5cb3..8834b3e0 100644
--- a/src/core/ExpectationResult.js
+++ b/src/core/ExpectationResult.js
@@ -12,6 +12,9 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
* @property {Boolean} passed - Whether the expectation passed or failed.
* @property {Object} expected - If the expectation failed, what was the expected value.
* @property {Object} actual - If the expectation failed, what actual value was produced.
+ * @property {String|undefined} globalErrorType - The type of an error that
+ * is reported on the top suite. Valid values are undefined, "afterAll",
+ * "load", "lateExpectation", and "lateError".
*/
var result = {
matcherName: options.matcherName,
diff --git a/src/html/HtmlReporter.js b/src/html/HtmlReporter.js
index 5cc4e86e..802c484d 100644
--- a/src/html/HtmlReporter.js
+++ b/src/html/HtmlReporter.js
@@ -272,8 +272,10 @@ jasmineRequire.HtmlReporter = function(j$) {
} else {
return prefix;
}
- } else {
+ } else if (failure.globalErrorType === 'afterAll') {
return afterAllMessagePrefix + failure.message;
+ } else {
+ return failure.message;
}
}