Suites report errors in afterAlls in the suiteDone event
- remove `afterAllEvent` from reporters
This commit is contained in:
@@ -20,7 +20,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
||||
yellow: '\x1B[33m',
|
||||
none: '\x1B[0m'
|
||||
},
|
||||
exceptionList = [];
|
||||
failedSuites = [];
|
||||
|
||||
this.jasmineStarted = function() {
|
||||
specCount = 0;
|
||||
@@ -52,10 +52,8 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
||||
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
||||
printNewline();
|
||||
|
||||
for(i = 0; i < exceptionList.length; i++) {
|
||||
printNewline();
|
||||
print(colored('red', 'AfterAll ' + exceptionList[i]));
|
||||
printNewline();
|
||||
for(i = 0; i < failedSuites.length; i++) {
|
||||
suiteFailureDetails(failedSuites[i]);
|
||||
}
|
||||
|
||||
onComplete(failureCount === 0);
|
||||
@@ -82,9 +80,11 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
||||
}
|
||||
};
|
||||
|
||||
this.afterAllEvent = function(error) {
|
||||
failureCount++;
|
||||
exceptionList.push(error);
|
||||
this.suiteDone = function(result) {
|
||||
if (result.failedExpectations && result.failedExpectations.length > 0) {
|
||||
failureCount++;
|
||||
failedSuites.push(result);
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
@@ -130,6 +130,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;
|
||||
|
||||
+6
-16
@@ -34,8 +34,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
'suiteStarted',
|
||||
'suiteDone',
|
||||
'specStarted',
|
||||
'specDone',
|
||||
'afterAllEvent'
|
||||
'specDone'
|
||||
]);
|
||||
|
||||
this.specFilter = function() {
|
||||
@@ -171,11 +170,6 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
options.catchException = catchException;
|
||||
options.clearStack = options.clearStack || clearStack;
|
||||
options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
|
||||
options.reportException = function(e, type) {
|
||||
if (type === 'afterAll') {
|
||||
reporter.afterAllEvent('Error thrown: '+ (e.message || e.description));
|
||||
}
|
||||
};
|
||||
|
||||
new j$.QueueRunner(options).execute();
|
||||
};
|
||||
@@ -185,8 +179,9 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
id: getNextSuiteId(),
|
||||
description: 'Jasmine__TopLevel__Suite',
|
||||
queueRunner: queueRunnerFactory,
|
||||
resultCallback: function() {}, // TODO - hook this up
|
||||
reportExpectationFailure: reportExpectationFailure
|
||||
resultCallback: function(attrs) {
|
||||
reporter.suiteDone(attrs);
|
||||
}
|
||||
});
|
||||
runnableLookupTable[topSuite.id] = topSuite;
|
||||
defaultResourcesForRunnable(topSuite.id);
|
||||
@@ -243,14 +238,14 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
queueRunner: queueRunnerFactory,
|
||||
onStart: suiteStarted,
|
||||
expectationFactory: expectationFactory,
|
||||
expectationResultFactory: expectationResultFactory,
|
||||
resultCallback: function(attrs) {
|
||||
if (!suite.disabled) {
|
||||
clearResourcesForRunnable(suite.id);
|
||||
currentlyExecutingSuites.pop();
|
||||
}
|
||||
reporter.suiteDone(attrs);
|
||||
},
|
||||
reportExpectationFailure: reportExpectationFailure
|
||||
}
|
||||
});
|
||||
|
||||
runnableLookupTable[suite.id] = suite;
|
||||
@@ -330,7 +325,6 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
id: getNextSpecId(),
|
||||
beforeAndAfterFns: beforeAndAfterFns(suite, runnablesExplictlySetGetter),
|
||||
expectationFactory: expectationFactory,
|
||||
exceptionFormatter: exceptionFormatter,
|
||||
resultCallback: specResultCallback,
|
||||
getSpecName: function(spec) {
|
||||
return getSpecName(spec, suite);
|
||||
@@ -410,10 +404,6 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
this.pending = function() {
|
||||
throw j$.Spec.pendingSpecExceptionMessage;
|
||||
};
|
||||
|
||||
function reportExpectationFailure(message) {
|
||||
reporter.afterAllEvent('Expectation failed: '+ message);
|
||||
}
|
||||
}
|
||||
|
||||
return Env;
|
||||
|
||||
@@ -18,7 +18,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
this.catchException = attrs.catchException || function() { return true; };
|
||||
this.userContext = attrs.userContext || {};
|
||||
this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
|
||||
this.reportException = attrs.reportException || function() {};
|
||||
}
|
||||
|
||||
QueueRunner.prototype.execute = function() {
|
||||
@@ -81,7 +80,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
}
|
||||
|
||||
function onException(e, queueableFn) {
|
||||
self.reportException(e, queueableFn.type);
|
||||
self.onException(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.beforeAndAfterFns = attrs.beforeAndAfterFns || function() { return {befores: [], afters: []}; };
|
||||
this.userContext = attrs.userContext || function() { return {}; };
|
||||
this.onStart = attrs.onStart || function() {};
|
||||
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
|
||||
this.getSpecName = attrs.getSpecName || function() { return ''; };
|
||||
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
||||
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
||||
|
||||
+27
-14
@@ -8,7 +8,7 @@ getJasmineRequireObj().Suite = function() {
|
||||
this.resultCallback = attrs.resultCallback || function() {};
|
||||
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
||||
this.expectationFactory = attrs.expectationFactory;
|
||||
this.reportExpectationFailure = attrs.reportExpectationFailure || function() {};
|
||||
this.expectationResultFactory = attrs.expectationResultFactory;
|
||||
|
||||
this.beforeFns = [];
|
||||
this.afterFns = [];
|
||||
@@ -23,7 +23,8 @@ getJasmineRequireObj().Suite = function() {
|
||||
id: this.id,
|
||||
status: this.disabled ? 'disabled' : '',
|
||||
description: this.description,
|
||||
fullName: this.getFullName()
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: []
|
||||
};
|
||||
}
|
||||
|
||||
@@ -130,31 +131,43 @@ getJasmineRequireObj().Suite = function() {
|
||||
};
|
||||
|
||||
Suite.prototype.onException = function() {
|
||||
for (var i = 0; i < this.children.length; i++) {
|
||||
var child = this.children[i];
|
||||
child.onException.apply(child, arguments);
|
||||
if(isAfterAll(this.children)) {
|
||||
var data = {
|
||||
matcherName: '',
|
||||
passed: false,
|
||||
expected: '',
|
||||
actual: '',
|
||||
error: arguments[0]
|
||||
};
|
||||
this.result.failedExpectations.push(this.expectationResultFactory(data));
|
||||
} else {
|
||||
for (var i = 0; i < this.children.length; i++) {
|
||||
var child = this.children[i];
|
||||
child.onException.apply(child, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Suite.prototype.addExpectationResult = function () {
|
||||
if(isAfterAll(this.children) && isFailure(arguments)){
|
||||
this.reportExpectationFailure(arguments[1].message);
|
||||
var data = arguments[1];
|
||||
this.result.failedExpectations.push(this.expectationResultFactory(data));
|
||||
} else {
|
||||
for (var i = 0; i < this.children.length; i++) {
|
||||
var child = this.children[i];
|
||||
child.addExpectationResult.apply(child, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
function isAfterAll(children) {
|
||||
return children && children[0].result.status;
|
||||
}
|
||||
|
||||
function isFailure(args) {
|
||||
return !args[0];
|
||||
}
|
||||
};
|
||||
|
||||
function isAfterAll(children) {
|
||||
return children && children[0].result.status;
|
||||
}
|
||||
|
||||
function isFailure(args) {
|
||||
return !args[0];
|
||||
}
|
||||
|
||||
function clone(obj) {
|
||||
var clonedObj = {};
|
||||
for (var prop in obj) {
|
||||
|
||||
@@ -18,7 +18,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
pendingSpecCount = 0,
|
||||
htmlReporterMain,
|
||||
symbols,
|
||||
exceptionList = [];
|
||||
failedSuites = [];
|
||||
|
||||
this.initialize = function() {
|
||||
htmlReporterMain = createDom('div', {className: 'html-reporter'},
|
||||
@@ -54,6 +54,10 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {
|
||||
if (result.failedExpectations && result.failedExpectations.length > 0) {
|
||||
failedSuites.push(result);
|
||||
}
|
||||
|
||||
if (currentParent == topResults) {
|
||||
return;
|
||||
}
|
||||
@@ -65,10 +69,6 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
currentParent.addChild(result, 'spec');
|
||||
};
|
||||
|
||||
this.afterAllEvent = function(error) {
|
||||
exceptionList.push(error);
|
||||
};
|
||||
|
||||
var failures = [];
|
||||
this.specDone = function(result) {
|
||||
if (result.status != 'disabled') {
|
||||
@@ -141,10 +141,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 = 'AfterAll ' + (exceptionList[i]);
|
||||
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');
|
||||
|
||||
Reference in New Issue
Block a user