Don't display late errors as AfterAll errors in the HTML reporter
This commit is contained in:
@@ -303,8 +303,10 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
} else {
|
} else {
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (failure.globalErrorType === 'afterAll') {
|
||||||
return afterAllMessagePrefix + failure.message;
|
return afterAllMessagePrefix + failure.message;
|
||||||
|
} else {
|
||||||
|
return failure.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1331,15 +1331,15 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function recordLateError(error) {
|
function recordLateError(error) {
|
||||||
topSuite.result.failedExpectations.push(
|
const result = expectationResultFactory({
|
||||||
expectationResultFactory({
|
error,
|
||||||
error,
|
passed: false,
|
||||||
passed: false,
|
matcherName: '',
|
||||||
matcherName: '',
|
expected: '',
|
||||||
expected: '',
|
actual: ''
|
||||||
actual: ''
|
});
|
||||||
})
|
result.globalErrorType = 'lateError';
|
||||||
);
|
topSuite.result.failedExpectations.push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function recordLateExpectation(runable, runableType, result) {
|
function recordLateExpectation(runable, runableType, result) {
|
||||||
@@ -3912,6 +3912,9 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
|
|||||||
* @property {Boolean} passed - Whether the expectation passed or failed.
|
* @property {Boolean} passed - Whether the expectation passed or failed.
|
||||||
* @property {Object} expected - If the expectation failed, what was the expected value.
|
* @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 {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 = {
|
var result = {
|
||||||
matcherName: options.matcherName,
|
matcherName: options.matcherName,
|
||||||
|
|||||||
@@ -534,9 +534,11 @@ describe('Env integration', function() {
|
|||||||
expect(errors[0].message)
|
expect(errors[0].message)
|
||||||
.withContext('top beforeAll')
|
.withContext('top beforeAll')
|
||||||
.toContain(message);
|
.toContain(message);
|
||||||
|
expect(errors[0].globalErrorType).toEqual('lateError');
|
||||||
expect(errors[1].message)
|
expect(errors[1].message)
|
||||||
.withContext('top afterAll')
|
.withContext('top afterAll')
|
||||||
.toContain(message);
|
.toContain(message);
|
||||||
|
expect(errors[1].globalErrorType).toEqual('lateError');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -568,9 +570,11 @@ describe('Env integration', function() {
|
|||||||
expect(errors[0].message)
|
expect(errors[0].message)
|
||||||
.withContext('suite beforeAll')
|
.withContext('suite beforeAll')
|
||||||
.toContain(message);
|
.toContain(message);
|
||||||
|
expect(errors[0].globalErrorType).toEqual('lateError');
|
||||||
expect(errors[1].message)
|
expect(errors[1].message)
|
||||||
.withContext('suite afterAll')
|
.withContext('suite afterAll')
|
||||||
.toContain(message);
|
.toContain(message);
|
||||||
|
expect(errors[1].globalErrorType).toEqual('lateError');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -605,12 +609,15 @@ describe('Env integration', function() {
|
|||||||
expect(errors[0].message)
|
expect(errors[0].message)
|
||||||
.withContext('error caused by beforeEach')
|
.withContext('error caused by beforeEach')
|
||||||
.toContain(message);
|
.toContain(message);
|
||||||
|
expect(errors[0].globalErrorType).toEqual('lateError');
|
||||||
expect(errors[1].message)
|
expect(errors[1].message)
|
||||||
.withContext('error caused by it')
|
.withContext('error caused by it')
|
||||||
.toContain(message);
|
.toContain(message);
|
||||||
|
expect(errors[1].globalErrorType).toEqual('lateError');
|
||||||
expect(errors[2].message)
|
expect(errors[2].message)
|
||||||
.withContext('error caused by afterEach')
|
.withContext('error caused by afterEach')
|
||||||
.toContain(message);
|
.toContain(message);
|
||||||
|
expect(errors[2].globalErrorType).toEqual('lateError');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -634,6 +641,7 @@ describe('Env integration', function() {
|
|||||||
.failedExpectations;
|
.failedExpectations;
|
||||||
expect(errors.length).toEqual(1);
|
expect(errors.length).toEqual(1);
|
||||||
expect(errors[0].message).toContain(message);
|
expect(errors[0].message).toContain(message);
|
||||||
|
expect(errors[0].globalErrorType).toEqual('lateError');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -704,6 +704,50 @@ describe('HtmlReporter', function() {
|
|||||||
expect(alertBars[2].innerHTML).not.toMatch(/line/);
|
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() {
|
it('displays file and line information if available', function() {
|
||||||
var container = document.createElement('div'),
|
var container = document.createElement('div'),
|
||||||
getContainer = function() {
|
getContainer = function() {
|
||||||
|
|||||||
@@ -339,15 +339,15 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function recordLateError(error) {
|
function recordLateError(error) {
|
||||||
topSuite.result.failedExpectations.push(
|
const result = expectationResultFactory({
|
||||||
expectationResultFactory({
|
error,
|
||||||
error,
|
passed: false,
|
||||||
passed: false,
|
matcherName: '',
|
||||||
matcherName: '',
|
expected: '',
|
||||||
expected: '',
|
actual: ''
|
||||||
actual: ''
|
});
|
||||||
})
|
result.globalErrorType = 'lateError';
|
||||||
);
|
topSuite.result.failedExpectations.push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function recordLateExpectation(runable, runableType, result) {
|
function recordLateExpectation(runable, runableType, result) {
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ getJasmineRequireObj().buildExpectationResult = function(j$) {
|
|||||||
* @property {Boolean} passed - Whether the expectation passed or failed.
|
* @property {Boolean} passed - Whether the expectation passed or failed.
|
||||||
* @property {Object} expected - If the expectation failed, what was the expected value.
|
* @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 {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 = {
|
var result = {
|
||||||
matcherName: options.matcherName,
|
matcherName: options.matcherName,
|
||||||
|
|||||||
@@ -272,8 +272,10 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
} else {
|
} else {
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (failure.globalErrorType === 'afterAll') {
|
||||||
return afterAllMessagePrefix + failure.message;
|
return afterAllMessagePrefix + failure.message;
|
||||||
|
} else {
|
||||||
|
return failure.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user