HtmlReporter shows error alerts for afterAllExceptions

-Add list of exceptions in HtmlReporter to push to on error
-Create alerts for each exception in the list (with stack trace)

[#67055688]
This commit is contained in:
Christopher Amavisca and Greg Cobb
2014-03-06 15:39:04 -08:00
parent 6caf4c5de2
commit bed1c15ea4
5 changed files with 43 additions and 15 deletions

View File

@@ -130,24 +130,33 @@ describe("New HtmlReporter", function() {
});
});
describe("when afterAllException is called", function () {
it("sends a console error", function(){
describe("when there are afterAllExceptions", function () {
it("displays the exceptions in their own alert bars", function(){
var env = new j$.Env(),
error = new Error('After all exception!'),
container = document.createElement('div'),
getContainer = function () { return container; },
container = document.createElement("div"),
getContainer = function() { return container; },
reporter = new j$.HtmlReporter({
env: env,
getContainer: getContainer,
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
getContainer: getContainer
});
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
}),
error = new Error('My After All Exception'),
otherError = new Error('My Other Exception');
reporter.initialize();
spyOn(window.console, 'error');
reporter.jasmineStarted({});
reporter.afterAllException(error);
expect(window.console.error).toHaveBeenCalled();
reporter.afterAllException(otherError);
reporter.jasmineDone({});
var alertBars = container.querySelectorAll(".alert .bar");
expect(alertBars.length).toEqual(3);
expect(alertBars[1].innerHTML).toMatch(/My After All Exception/);
expect(alertBars[1].getAttribute("class")).toEqual('bar errored');
expect(alertBars[2].innerHTML).toMatch(/My Other Exception/);
});
});