Skip to content

Commit

Permalink
Suites report errors in afterAlls in the suiteDone event
Browse files Browse the repository at this point in the history
- remove `afterAllEvent` from reporters
  • Loading branch information
slackersoft committed Sep 4, 2014
1 parent 6b857d1 commit 9402d59
Show file tree
Hide file tree
Showing 14 changed files with 305 additions and 202 deletions.
28 changes: 19 additions & 9 deletions lib/console/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
yellow: '\x1B[33m',
none: '\x1B[0m'
},
exceptionList = [];
failedSuites = [];

this.jasmineStarted = function() {
specCount = 0;
Expand Down Expand Up @@ -87,12 +87,8 @@ getJasmineRequireObj().ConsoleReporter = function() {
print('Finished in ' + seconds + ' ' + plural('second', seconds));
printNewline();

for(i = 0; i < exceptionList.length; i++) {
printNewline();
print(colored('red', 'An error was thrown in an afterAll'));
printNewline();
print(colored('red', (exceptionList[i].message || exceptionList[i].description)));
printNewline();
for(i = 0; i < failedSuites.length; i++) {
suiteFailureDetails(failedSuites[i]);
}

onComplete(failureCount === 0);
Expand All @@ -119,8 +115,11 @@ getJasmineRequireObj().ConsoleReporter = function() {
}
};

this.afterAllError = function(error) {
exceptionList.push(error);
this.suiteDone = function(result) {
if (result.failedExpectations && result.failedExpectations.length > 0) {
failureCount++;
failedSuites.push(result);
}
};

return this;
Expand Down Expand Up @@ -166,6 +165,17 @@ getJasmineRequireObj().ConsoleReporter = function() {

printNewline();
}

function suiteFailureDetails(result) {
for (var i = 0; i < result.failedExpectations.length; i++) {
printNewline();
print(colored('red', 'An error was thrown in an afterAll'));
printNewline();
print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));

}
printNewline();
}
}

return ConsoleReporter;
Expand Down
21 changes: 12 additions & 9 deletions lib/jasmine-core/jasmine-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jasmineRequire.HtmlReporter = function(j$) {
pendingSpecCount = 0,
htmlReporterMain,
symbols,
exceptionList = [];
failedSuites = [];

this.initialize = function() {
htmlReporterMain = createDom('div', {className: 'html-reporter'},
Expand Down Expand Up @@ -83,6 +83,10 @@ jasmineRequire.HtmlReporter = function(j$) {
};

this.suiteDone = function(result) {
if (result.failedExpectations && result.failedExpectations.length > 0) {
failedSuites.push(result);
}

if (currentParent == topResults) {
return;
}
Expand All @@ -94,10 +98,6 @@ jasmineRequire.HtmlReporter = function(j$) {
currentParent.addChild(result, 'spec');
};

this.afterAllException = function(error) {
exceptionList.push(error);
};

var failures = [];
this.specDone = function(result) {
if (result.status != 'disabled') {
Expand Down Expand Up @@ -170,10 +170,13 @@ jasmineRequire.HtmlReporter = function(j$) {
var statusBarClassName = 'bar ' + ((failureCount > 0) ? 'failed' : 'passed');
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));

for(i = 0; i < exceptionList.length; i++) {
var errorBarMessage = 'An error was thrown in an afterAll: ' + (exceptionList[i].message || exceptionList[i].description);
var errorBarClassName = 'bar errored';
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
for(i = 0; i < failedSuites.length; i++) {
var failedSuite = failedSuites[i];
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
var errorBarClassName = 'bar errored';
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
}
}

var results = find('.results');
Expand Down
Loading

0 comments on commit 9402d59

Please sign in to comment.