Fix issues with displaying error messages for afterAll (browser compatibility)

- Switch from showing error stack to showing message/description since only chrome/ff support stack
- Fallback to error.description if error.message is undefined
- Made exceptionList variable name consistent between both reporters
This commit is contained in:
Christopher Amavisca and Greg Cobb
2014-03-06 18:25:49 -08:00
parent 76fafa0388
commit 668846147c
5 changed files with 17 additions and 17 deletions

View File

@@ -87,13 +87,13 @@ getJasmineRequireObj().ConsoleReporter = function() {
print('Finished in ' + seconds + ' ' + plural('second', seconds)); print('Finished in ' + seconds + ' ' + plural('second', seconds));
printNewline(); printNewline();
exceptionList.forEach(function(error) { for(i = 0; i < exceptionList.length; i++) {
printNewline(); printNewline();
print(colored('red', 'An error was thrown in an afterAll')); print(colored('red', 'An error was thrown in an afterAll'));
printNewline(); printNewline();
print(colored('red', error.stack)); print(colored('red', (exceptionList[i].message || exceptionList[i].description)));
printNewline(); printNewline();
}); }
onComplete(failureCount === 0); onComplete(failureCount === 0);
}; };

View File

@@ -47,7 +47,7 @@ jasmineRequire.HtmlReporter = function(j$) {
pendingSpecCount = 0, pendingSpecCount = 0,
htmlReporterMain, htmlReporterMain,
symbols, symbols,
exceptionsList = []; exceptionList = [];
this.initialize = function() { this.initialize = function() {
htmlReporterMain = createDom('div', {className: 'html-reporter'}, htmlReporterMain = createDom('div', {className: 'html-reporter'},
@@ -95,7 +95,7 @@ jasmineRequire.HtmlReporter = function(j$) {
}; };
this.afterAllException = function(error) { this.afterAllException = function(error) {
exceptionsList.push(error); exceptionList.push(error);
}; };
var failures = []; var failures = [];
@@ -170,11 +170,11 @@ jasmineRequire.HtmlReporter = function(j$) {
var statusBarClassName = 'bar ' + ((failureCount > 0) ? 'failed' : 'passed'); var statusBarClassName = 'bar ' + ((failureCount > 0) ? 'failed' : 'passed');
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage)); alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
exceptionsList.forEach(function(error) { for(i = 0; i < exceptionList.length; i++) {
var errorBarMessage = 'An error was thrown in an afterAll: ' + error.stack; var errorBarMessage = 'An error was thrown in an afterAll: ' + (exceptionList[i].message || exceptionList[i].description);
var errorBarClassName = 'bar errored'; var errorBarClassName = 'bar errored';
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage)); alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
}); }
var results = find('.results'); var results = find('.results');
results.appendChild(summary); results.appendChild(summary);

View File

@@ -52,13 +52,13 @@ getJasmineRequireObj().ConsoleReporter = function() {
print('Finished in ' + seconds + ' ' + plural('second', seconds)); print('Finished in ' + seconds + ' ' + plural('second', seconds));
printNewline(); printNewline();
exceptionList.forEach(function(error) { for(i = 0; i < exceptionList.length; i++) {
printNewline(); printNewline();
print(colored('red', 'An error was thrown in an afterAll')); print(colored('red', 'An error was thrown in an afterAll'));
printNewline(); printNewline();
print(colored('red', error.stack)); print(colored('red', (exceptionList[i].message || exceptionList[i].description)));
printNewline(); printNewline();
}); }
onComplete(failureCount === 0); onComplete(failureCount === 0);
}; };

View File

@@ -18,7 +18,7 @@ jasmineRequire.HtmlReporter = function(j$) {
pendingSpecCount = 0, pendingSpecCount = 0,
htmlReporterMain, htmlReporterMain,
symbols, symbols,
exceptionsList = []; exceptionList = [];
this.initialize = function() { this.initialize = function() {
htmlReporterMain = createDom('div', {className: 'html-reporter'}, htmlReporterMain = createDom('div', {className: 'html-reporter'},
@@ -66,7 +66,7 @@ jasmineRequire.HtmlReporter = function(j$) {
}; };
this.afterAllException = function(error) { this.afterAllException = function(error) {
exceptionsList.push(error); exceptionList.push(error);
}; };
var failures = []; var failures = [];
@@ -141,11 +141,11 @@ jasmineRequire.HtmlReporter = function(j$) {
var statusBarClassName = 'bar ' + ((failureCount > 0) ? 'failed' : 'passed'); var statusBarClassName = 'bar ' + ((failureCount > 0) ? 'failed' : 'passed');
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage)); alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
exceptionsList.forEach(function(error) { for(i = 0; i < exceptionList.length; i++) {
var errorBarMessage = 'An error was thrown in an afterAll: ' + error.stack; var errorBarMessage = 'An error was thrown in an afterAll: ' + (exceptionList[i].message || exceptionList[i].description);
var errorBarClassName = 'bar errored'; var errorBarClassName = 'bar errored';
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage)); alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
}); }
var results = find('.results'); var results = find('.results');
results.appendChild(summary); results.appendChild(summary);