Suites report errors in afterAlls in the suiteDone event
- remove `afterAllEvent` from reporters
This commit is contained in:
@@ -55,7 +55,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
yellow: '\x1B[33m',
|
yellow: '\x1B[33m',
|
||||||
none: '\x1B[0m'
|
none: '\x1B[0m'
|
||||||
},
|
},
|
||||||
exceptionList = [];
|
failedSuites = [];
|
||||||
|
|
||||||
this.jasmineStarted = function() {
|
this.jasmineStarted = function() {
|
||||||
specCount = 0;
|
specCount = 0;
|
||||||
@@ -87,12 +87,8 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
||||||
printNewline();
|
printNewline();
|
||||||
|
|
||||||
for(i = 0; i < exceptionList.length; i++) {
|
for(i = 0; i < failedSuites.length; i++) {
|
||||||
printNewline();
|
suiteFailureDetails(failedSuites[i]);
|
||||||
print(colored('red', 'An error was thrown in an afterAll'));
|
|
||||||
printNewline();
|
|
||||||
print(colored('red', (exceptionList[i].message || exceptionList[i].description)));
|
|
||||||
printNewline();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onComplete(failureCount === 0);
|
onComplete(failureCount === 0);
|
||||||
@@ -119,8 +115,11 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.afterAllError = function(error) {
|
this.suiteDone = function(result) {
|
||||||
exceptionList.push(error);
|
if (result.failedExpectations && result.failedExpectations.length > 0) {
|
||||||
|
failureCount++;
|
||||||
|
failedSuites.push(result);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -166,6 +165,17 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
|
|
||||||
printNewline();
|
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;
|
return ConsoleReporter;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
pendingSpecCount = 0,
|
pendingSpecCount = 0,
|
||||||
htmlReporterMain,
|
htmlReporterMain,
|
||||||
symbols,
|
symbols,
|
||||||
exceptionList = [];
|
failedSuites = [];
|
||||||
|
|
||||||
this.initialize = function() {
|
this.initialize = function() {
|
||||||
htmlReporterMain = createDom('div', {className: 'html-reporter'},
|
htmlReporterMain = createDom('div', {className: 'html-reporter'},
|
||||||
@@ -83,6 +83,10 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.suiteDone = function(result) {
|
this.suiteDone = function(result) {
|
||||||
|
if (result.failedExpectations && result.failedExpectations.length > 0) {
|
||||||
|
failedSuites.push(result);
|
||||||
|
}
|
||||||
|
|
||||||
if (currentParent == topResults) {
|
if (currentParent == topResults) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -94,10 +98,6 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
currentParent.addChild(result, 'spec');
|
currentParent.addChild(result, 'spec');
|
||||||
};
|
};
|
||||||
|
|
||||||
this.afterAllException = function(error) {
|
|
||||||
exceptionList.push(error);
|
|
||||||
};
|
|
||||||
|
|
||||||
var failures = [];
|
var failures = [];
|
||||||
this.specDone = function(result) {
|
this.specDone = function(result) {
|
||||||
if (result.status != 'disabled') {
|
if (result.status != 'disabled') {
|
||||||
@@ -170,10 +170,13 @@ 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));
|
||||||
|
|
||||||
for(i = 0; i < exceptionList.length; i++) {
|
for(i = 0; i < failedSuites.length; i++) {
|
||||||
var errorBarMessage = 'An error was thrown in an afterAll: ' + (exceptionList[i].message || exceptionList[i].description);
|
var failedSuite = failedSuites[i];
|
||||||
var errorBarClassName = 'bar errored';
|
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
|
||||||
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
|
var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
|
||||||
|
var errorBarClassName = 'bar errored';
|
||||||
|
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = find('.results');
|
var results = find('.results');
|
||||||
|
|||||||
@@ -250,11 +250,9 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
this.id = attrs.id;
|
this.id = attrs.id;
|
||||||
this.description = attrs.description || '';
|
this.description = attrs.description || '';
|
||||||
this.queueableFn = attrs.queueableFn;
|
this.queueableFn = attrs.queueableFn;
|
||||||
this.beforeFns = attrs.beforeFns || function() { return []; };
|
this.beforeAndAfterFns = attrs.beforeAndAfterFns || function() { return {befores: [], afters: []}; };
|
||||||
this.afterFns = attrs.afterFns || function() { return []; };
|
|
||||||
this.userContext = attrs.userContext || function() { return {}; };
|
this.userContext = attrs.userContext || function() { return {}; };
|
||||||
this.onStart = attrs.onStart || function() {};
|
this.onStart = attrs.onStart || function() {};
|
||||||
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
|
|
||||||
this.getSpecName = attrs.getSpecName || function() { return ''; };
|
this.getSpecName = attrs.getSpecName || function() { return ''; };
|
||||||
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
||||||
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
||||||
@@ -293,7 +291,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var allFns = this.beforeFns().concat(this.queueableFn).concat(this.afterFns());
|
var fns = this.beforeAndAfterFns();
|
||||||
|
var allFns = fns.befores.concat(this.queueableFn).concat(fns.afters);
|
||||||
|
|
||||||
this.queueRunnerFactory({
|
this.queueRunnerFactory({
|
||||||
queueableFns: allFns,
|
queueableFns: allFns,
|
||||||
@@ -408,8 +407,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
'suiteStarted',
|
'suiteStarted',
|
||||||
'suiteDone',
|
'suiteDone',
|
||||||
'specStarted',
|
'specStarted',
|
||||||
'specDone',
|
'specDone'
|
||||||
'afterAllException'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.specFilter = function() {
|
this.specFilter = function() {
|
||||||
@@ -475,25 +473,28 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
delete runnableResources[id];
|
delete runnableResources[id];
|
||||||
};
|
};
|
||||||
|
|
||||||
var beforeFns = function(suite) {
|
var beforeAndAfterFns = function(suite, runnablesExplictlySet) {
|
||||||
return function() {
|
return function() {
|
||||||
var befores = [];
|
var befores = [],
|
||||||
|
afters = [],
|
||||||
|
beforeAlls = [],
|
||||||
|
afterAlls = [];
|
||||||
|
|
||||||
while(suite) {
|
while(suite) {
|
||||||
befores = befores.concat(suite.beforeFns);
|
befores = befores.concat(suite.beforeFns);
|
||||||
suite = suite.parentSuite;
|
|
||||||
}
|
|
||||||
return befores.reverse();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var afterFns = function(suite) {
|
|
||||||
return function() {
|
|
||||||
var afters = [];
|
|
||||||
while(suite) {
|
|
||||||
afters = afters.concat(suite.afterFns);
|
afters = afters.concat(suite.afterFns);
|
||||||
|
|
||||||
|
if (runnablesExplictlySet()) {
|
||||||
|
beforeAlls = beforeAlls.concat(suite.beforeAllFns);
|
||||||
|
afterAlls = afterAlls.concat(suite.afterAllFns);
|
||||||
|
}
|
||||||
|
|
||||||
suite = suite.parentSuite;
|
suite = suite.parentSuite;
|
||||||
}
|
}
|
||||||
return afters;
|
return {
|
||||||
|
befores: beforeAlls.reverse().concat(befores.reverse()),
|
||||||
|
afters: afters.concat(afterAlls)
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -540,7 +541,6 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
|
|
||||||
var queueRunnerFactory = function(options) {
|
var queueRunnerFactory = function(options) {
|
||||||
options.catchException = catchException;
|
options.catchException = catchException;
|
||||||
options.reporter = reporter;
|
|
||||||
options.clearStack = options.clearStack || clearStack;
|
options.clearStack = options.clearStack || clearStack;
|
||||||
options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
|
options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
|
||||||
|
|
||||||
@@ -552,7 +552,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
id: getNextSuiteId(),
|
id: getNextSuiteId(),
|
||||||
description: 'Jasmine__TopLevel__Suite',
|
description: 'Jasmine__TopLevel__Suite',
|
||||||
queueRunner: queueRunnerFactory,
|
queueRunner: queueRunnerFactory,
|
||||||
resultCallback: function() {} // TODO - hook this up
|
resultCallback: function(attrs) {
|
||||||
|
reporter.suiteDone(attrs);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
runnableLookupTable[topSuite.id] = topSuite;
|
runnableLookupTable[topSuite.id] = topSuite;
|
||||||
defaultResourcesForRunnable(topSuite.id);
|
defaultResourcesForRunnable(topSuite.id);
|
||||||
@@ -563,7 +565,14 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.execute = function(runnablesToRun) {
|
this.execute = function(runnablesToRun) {
|
||||||
runnablesToRun = runnablesToRun || [topSuite.id];
|
if(runnablesToRun) {
|
||||||
|
runnablesExplictlySet = true;
|
||||||
|
} else if (focusedRunnables.length) {
|
||||||
|
runnablesExplictlySet = true;
|
||||||
|
runnablesToRun = focusedRunnables;
|
||||||
|
} else {
|
||||||
|
runnablesToRun = [topSuite.id];
|
||||||
|
}
|
||||||
|
|
||||||
var allFns = [];
|
var allFns = [];
|
||||||
for(var i = 0; i < runnablesToRun.length; i++) {
|
for(var i = 0; i < runnablesToRun.length; i++) {
|
||||||
@@ -602,6 +611,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
queueRunner: queueRunnerFactory,
|
queueRunner: queueRunnerFactory,
|
||||||
onStart: suiteStarted,
|
onStart: suiteStarted,
|
||||||
expectationFactory: expectationFactory,
|
expectationFactory: expectationFactory,
|
||||||
|
expectationResultFactory: expectationResultFactory,
|
||||||
resultCallback: function(attrs) {
|
resultCallback: function(attrs) {
|
||||||
if (!suite.disabled) {
|
if (!suite.disabled) {
|
||||||
clearResourcesForRunnable(suite.id);
|
clearResourcesForRunnable(suite.id);
|
||||||
@@ -623,7 +633,28 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
|
|
||||||
this.describe = function(description, specDefinitions) {
|
this.describe = function(description, specDefinitions) {
|
||||||
var suite = suiteFactory(description);
|
var suite = suiteFactory(description);
|
||||||
|
addSpecsToSuite(suite, specDefinitions);
|
||||||
|
return suite;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.xdescribe = function(description, specDefinitions) {
|
||||||
|
var suite = this.describe(description, specDefinitions);
|
||||||
|
suite.disable();
|
||||||
|
return suite;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.fdescribe = function(description, specDefinitions) {
|
||||||
|
var suite = suiteFactory(description);
|
||||||
|
suite.isFocused = true;
|
||||||
|
addSpecsToSuite(suite, specDefinitions);
|
||||||
|
|
||||||
|
if (!hasFocusedAncestor(suite.parentSuite)) {
|
||||||
|
focusedRunnables.push(suite.id);
|
||||||
|
}
|
||||||
|
return suite;
|
||||||
|
};
|
||||||
|
|
||||||
|
function addSpecsToSuite(suite, specDefinitions) {
|
||||||
var parentSuite = currentDeclarationSuite;
|
var parentSuite = currentDeclarationSuite;
|
||||||
parentSuite.addChild(suite);
|
parentSuite.addChild(suite);
|
||||||
currentDeclarationSuite = suite;
|
currentDeclarationSuite = suite;
|
||||||
@@ -636,31 +667,37 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (declarationError) {
|
if (declarationError) {
|
||||||
this.it('encountered a declaration exception', function() {
|
self.it('encountered a declaration exception', function() {
|
||||||
throw declarationError;
|
throw declarationError;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDeclarationSuite = parentSuite;
|
currentDeclarationSuite = parentSuite;
|
||||||
|
}
|
||||||
|
|
||||||
return suite;
|
function hasFocusedAncestor(suite) {
|
||||||
};
|
while (suite) {
|
||||||
|
if (suite.isFocused) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
suite = suite.parentSuite;
|
||||||
|
}
|
||||||
|
|
||||||
this.xdescribe = function(description, specDefinitions) {
|
return false;
|
||||||
var suite = this.describe(description, specDefinitions);
|
}
|
||||||
suite.disable();
|
|
||||||
return suite;
|
var runnablesExplictlySet = false;
|
||||||
|
|
||||||
|
var runnablesExplictlySetGetter = function(){
|
||||||
|
return runnablesExplictlySet;
|
||||||
};
|
};
|
||||||
|
|
||||||
var specFactory = function(description, fn, suite) {
|
var specFactory = function(description, fn, suite) {
|
||||||
totalSpecsDefined++;
|
totalSpecsDefined++;
|
||||||
|
|
||||||
var spec = new j$.Spec({
|
var spec = new j$.Spec({
|
||||||
id: getNextSpecId(),
|
id: getNextSpecId(),
|
||||||
beforeFns: beforeFns(suite),
|
beforeAndAfterFns: beforeAndAfterFns(suite, runnablesExplictlySetGetter),
|
||||||
afterFns: afterFns(suite),
|
|
||||||
expectationFactory: expectationFactory,
|
expectationFactory: expectationFactory,
|
||||||
exceptionFormatter: exceptionFormatter,
|
|
||||||
resultCallback: specResultCallback,
|
resultCallback: specResultCallback,
|
||||||
getSpecName: function(spec) {
|
getSpecName: function(spec) {
|
||||||
return getSpecName(spec, suite);
|
return getSpecName(spec, suite);
|
||||||
@@ -670,7 +707,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
expectationResultFactory: expectationResultFactory,
|
expectationResultFactory: expectationResultFactory,
|
||||||
queueRunnerFactory: queueRunnerFactory,
|
queueRunnerFactory: queueRunnerFactory,
|
||||||
userContext: function() { return suite.clonedSharedUserContext(); },
|
userContext: function() { return suite.clonedSharedUserContext(); },
|
||||||
queueableFn: { fn: fn, timeout: function() { return j$.DEFAULT_TIMEOUT_INTERVAL; } }
|
queueableFn: { fn: fn, type: 'it', timeout: function() { return j$.DEFAULT_TIMEOUT_INTERVAL; } }
|
||||||
});
|
});
|
||||||
|
|
||||||
runnableLookupTable[spec.id] = spec;
|
runnableLookupTable[spec.id] = spec;
|
||||||
@@ -706,24 +743,35 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return spec;
|
return spec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var focusedRunnables = [];
|
||||||
|
this.fit = function(description, fn ){
|
||||||
|
var spec = this.it(description, fn);
|
||||||
|
|
||||||
|
if (!hasFocusedAncestor(currentDeclarationSuite)) {
|
||||||
|
focusedRunnables.push(spec.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return spec;
|
||||||
|
};
|
||||||
|
|
||||||
this.expect = function(actual) {
|
this.expect = function(actual) {
|
||||||
return currentRunnable().expect(actual);
|
return currentRunnable().expect(actual);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.beforeEach = function(beforeEachFunction) {
|
this.beforeEach = function(beforeEachFunction) {
|
||||||
currentDeclarationSuite.beforeEach({ fn: beforeEachFunction, timeout: function() { return j$.DEFAULT_TIMEOUT_INTERVAL; } });
|
currentDeclarationSuite.beforeEach({ fn: beforeEachFunction, type: 'beforeEach', timeout: function() { return j$.DEFAULT_TIMEOUT_INTERVAL; } });
|
||||||
};
|
};
|
||||||
|
|
||||||
this.beforeAll = function(beforeAllFunction) {
|
this.beforeAll = function(beforeAllFunction) {
|
||||||
currentDeclarationSuite.beforeAll({ fn: beforeAllFunction, timeout: function() { return j$.DEFAULT_TIMEOUT_INTERVAL; } });
|
currentDeclarationSuite.beforeAll({ fn: beforeAllFunction, type: 'beforeAll', timeout: function() { return j$.DEFAULT_TIMEOUT_INTERVAL; } });
|
||||||
};
|
};
|
||||||
|
|
||||||
this.afterEach = function(afterEachFunction) {
|
this.afterEach = function(afterEachFunction) {
|
||||||
currentDeclarationSuite.afterEach({ fn: afterEachFunction, timeout: function() { return j$.DEFAULT_TIMEOUT_INTERVAL; } });
|
currentDeclarationSuite.afterEach({ fn: afterEachFunction, type: 'afterEach', timeout: function() { return j$.DEFAULT_TIMEOUT_INTERVAL; } });
|
||||||
};
|
};
|
||||||
|
|
||||||
this.afterAll = function(afterAllFunction) {
|
this.afterAll = function(afterAllFunction) {
|
||||||
currentDeclarationSuite.afterAll({ fn: afterAllFunction, isAfterAll: true, timeout: function() { return j$.DEFAULT_TIMEOUT_INTERVAL; } });
|
currentDeclarationSuite.afterAll({ fn: afterAllFunction, type: 'afterAll', timeout: function() { return j$.DEFAULT_TIMEOUT_INTERVAL; } });
|
||||||
};
|
};
|
||||||
|
|
||||||
this.pending = function() {
|
this.pending = function() {
|
||||||
@@ -1583,7 +1631,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
this.catchException = attrs.catchException || function() { return true; };
|
this.catchException = attrs.catchException || function() { return true; };
|
||||||
this.userContext = attrs.userContext || {};
|
this.userContext = attrs.userContext || {};
|
||||||
this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
|
this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
|
||||||
this.reporter = attrs.reporter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueRunner.prototype.execute = function() {
|
QueueRunner.prototype.execute = function() {
|
||||||
@@ -1591,10 +1638,10 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
QueueRunner.prototype.run = function(queueableFns, recursiveIndex) {
|
QueueRunner.prototype.run = function(queueableFns, recursiveIndex) {
|
||||||
var runner = this,
|
var length = queueableFns.length,
|
||||||
length = queueableFns.length,
|
self = this,
|
||||||
self = this,
|
iterativeIndex;
|
||||||
iterativeIndex;
|
|
||||||
|
|
||||||
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
||||||
var queueableFn = queueableFns[iterativeIndex];
|
var queueableFn = queueableFns[iterativeIndex];
|
||||||
@@ -1615,10 +1662,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
try {
|
try {
|
||||||
queueableFn.fn.call(self.userContext);
|
queueableFn.fn.call(self.userContext);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if(queueableFn.isAfterAll){
|
handleException(e, queueableFn);
|
||||||
runner.reporter.afterAllException(e);
|
|
||||||
}
|
|
||||||
handleException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1634,7 +1678,8 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
|
|
||||||
if (queueableFn.timeout) {
|
if (queueableFn.timeout) {
|
||||||
timeoutId = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
|
timeoutId = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
|
||||||
self.onException(new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'));
|
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
|
||||||
|
onException(error, queueableFn);
|
||||||
next();
|
next();
|
||||||
}, queueableFn.timeout()]]);
|
}, queueableFn.timeout()]]);
|
||||||
}
|
}
|
||||||
@@ -1642,16 +1687,17 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
try {
|
try {
|
||||||
queueableFn.fn.call(self.userContext, next);
|
queueableFn.fn.call(self.userContext, next);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if(queueableFn.isAfterAll) {
|
handleException(e, queueableFn);
|
||||||
runner.reporter.afterAllException(e);
|
|
||||||
}
|
|
||||||
handleException(e);
|
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleException(e) {
|
function onException(e, queueableFn) {
|
||||||
self.onException(e);
|
self.onException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleException(e, queueableFn) {
|
||||||
|
onException(e, queueableFn);
|
||||||
if (!self.catchException(e)) {
|
if (!self.catchException(e)) {
|
||||||
//TODO: set a var when we catch an exception and
|
//TODO: set a var when we catch an exception and
|
||||||
//use a finally block to close the loop in a nice way..
|
//use a finally block to close the loop in a nice way..
|
||||||
@@ -1807,6 +1853,7 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
this.resultCallback = attrs.resultCallback || function() {};
|
this.resultCallback = attrs.resultCallback || function() {};
|
||||||
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
||||||
this.expectationFactory = attrs.expectationFactory;
|
this.expectationFactory = attrs.expectationFactory;
|
||||||
|
this.expectationResultFactory = attrs.expectationResultFactory;
|
||||||
|
|
||||||
this.beforeFns = [];
|
this.beforeFns = [];
|
||||||
this.afterFns = [];
|
this.afterFns = [];
|
||||||
@@ -1821,7 +1868,8 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
id: this.id,
|
id: this.id,
|
||||||
status: this.disabled ? 'disabled' : '',
|
status: this.disabled ? 'disabled' : '',
|
||||||
description: this.description,
|
description: this.description,
|
||||||
fullName: this.getFullName()
|
fullName: this.getFullName(),
|
||||||
|
failedExpectations: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1873,7 +1921,7 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
var allFns = [];
|
var allFns = [];
|
||||||
|
|
||||||
if (this.isExecutable()) {
|
if (this.isExecutable()) {
|
||||||
allFns = this.beforeAllFns;
|
allFns = allFns.concat(this.beforeAllFns);
|
||||||
|
|
||||||
for (var i = 0; i < this.children.length; i++) {
|
for (var i = 0; i < this.children.length; i++) {
|
||||||
allFns.push(wrapChildAsAsync(this.children[i]));
|
allFns.push(wrapChildAsAsync(this.children[i]));
|
||||||
@@ -1928,19 +1976,43 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Suite.prototype.onException = function() {
|
Suite.prototype.onException = function() {
|
||||||
for (var i = 0; i < this.children.length; i++) {
|
if(isAfterAll(this.children)) {
|
||||||
var child = this.children[i];
|
var data = {
|
||||||
child.onException.apply(child, arguments);
|
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 () {
|
Suite.prototype.addExpectationResult = function () {
|
||||||
for (var i = 0; i < this.children.length; i++) {
|
if(isAfterAll(this.children) && isFailure(arguments)){
|
||||||
var child = this.children[i];
|
var data = arguments[1];
|
||||||
child.addExpectationResult.apply(child, arguments);
|
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 clone(obj) {
|
function clone(obj) {
|
||||||
var clonedObj = {};
|
var clonedObj = {};
|
||||||
for (var prop in obj) {
|
for (var prop in obj) {
|
||||||
|
|||||||
@@ -187,9 +187,9 @@ describe("ConsoleReporter", function() {
|
|||||||
expect(onComplete).toHaveBeenCalledWith(false);
|
expect(onComplete).toHaveBeenCalledWith(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls it with false if there are afterAll events', function() {
|
it('calls it with false if there are suite failures', function() {
|
||||||
reporter.afterAllEvent("bananas");
|
|
||||||
reporter.specDone({status: "passed"});
|
reporter.specDone({status: "passed"});
|
||||||
|
reporter.suiteDone({failedExpectations: [{ message: 'bananas' }] });
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone();
|
||||||
expect(onComplete).toHaveBeenCalledWith(false);
|
expect(onComplete).toHaveBeenCalledWith(false);
|
||||||
});
|
});
|
||||||
@@ -244,12 +244,10 @@ describe("ConsoleReporter", function() {
|
|||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new j$.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
showColors: true
|
showColors: true
|
||||||
}),
|
});
|
||||||
error = new Error('After All Exception'),
|
|
||||||
anotherError = new Error('Some Other Exception');
|
|
||||||
|
|
||||||
reporter.afterAllEvent(error);
|
reporter.suiteDone({ failedExpectations: [{ message: 'After All Exception' }] });
|
||||||
reporter.afterAllEvent(anotherError);
|
reporter.suiteDone({ failedExpectations: [{ message: 'Some Other Exception' }] });
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone();
|
||||||
|
|
||||||
expect(out.getOutput()).toMatch(/After All Exception/);
|
expect(out.getOutput()).toMatch(/After All Exception/);
|
||||||
|
|||||||
@@ -98,12 +98,10 @@ describe("QueueRunner", function() {
|
|||||||
beforeFn = { fn: function(done) { }, type: 'before', timeout: function() { return timeout; } },
|
beforeFn = { fn: function(done) { }, type: 'before', timeout: function() { return timeout; } },
|
||||||
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
onComplete = jasmine.createSpy('onComplete'),
|
||||||
reportException = jasmine.createSpy('reportException'),
|
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new j$.QueueRunner({
|
||||||
queueableFns: [beforeFn, queueableFn],
|
queueableFns: [beforeFn, queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
reportException: reportException,
|
|
||||||
onException: onException
|
onException: onException
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -112,7 +110,6 @@ describe("QueueRunner", function() {
|
|||||||
|
|
||||||
jasmine.clock().tick(timeout);
|
jasmine.clock().tick(timeout);
|
||||||
|
|
||||||
expect(reportException).toHaveBeenCalledWith(jasmine.any(Error), 'before');
|
|
||||||
expect(onException).toHaveBeenCalledWith(jasmine.any(Error));
|
expect(onException).toHaveBeenCalledWith(jasmine.any(Error));
|
||||||
expect(queueableFn.fn).toHaveBeenCalled();
|
expect(queueableFn.fn).toHaveBeenCalled();
|
||||||
expect(onComplete).toHaveBeenCalled();
|
expect(onComplete).toHaveBeenCalled();
|
||||||
@@ -122,12 +119,10 @@ describe("QueueRunner", function() {
|
|||||||
var beforeFn = { fn: function(done) { } },
|
var beforeFn = { fn: function(done) { } },
|
||||||
queueableFn = { fn: jasmine.createSpy('fn') },
|
queueableFn = { fn: jasmine.createSpy('fn') },
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
onComplete = jasmine.createSpy('onComplete'),
|
||||||
reportException = jasmine.createSpy('reportException'),
|
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new j$.QueueRunner({
|
||||||
queueableFns: [beforeFn, queueableFn],
|
queueableFns: [beforeFn, queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
reportException: reportException,
|
|
||||||
onException: onException,
|
onException: onException,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -136,7 +131,6 @@ describe("QueueRunner", function() {
|
|||||||
|
|
||||||
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
|
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
|
||||||
|
|
||||||
expect(reportException).not.toHaveBeenCalled();
|
|
||||||
expect(onException).not.toHaveBeenCalled();
|
expect(onException).not.toHaveBeenCalled();
|
||||||
expect(queueableFn.fn).not.toHaveBeenCalled();
|
expect(queueableFn.fn).not.toHaveBeenCalled();
|
||||||
expect(onComplete).not.toHaveBeenCalled();
|
expect(onComplete).not.toHaveBeenCalled();
|
||||||
@@ -145,35 +139,29 @@ describe("QueueRunner", function() {
|
|||||||
it("clears the timeout when an async function throws an exception, to prevent additional exception reporting", function() {
|
it("clears the timeout when an async function throws an exception, to prevent additional exception reporting", function() {
|
||||||
var queueableFn = { fn: function(done) { throw new Error("error!"); } },
|
var queueableFn = { fn: function(done) { throw new Error("error!"); } },
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
onComplete = jasmine.createSpy('onComplete'),
|
||||||
reportException = jasmine.createSpy('reportException'),
|
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new j$.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
reportException: reportException,
|
|
||||||
onException: onException
|
onException: onException
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
expect(onComplete).toHaveBeenCalled();
|
expect(onComplete).toHaveBeenCalled();
|
||||||
expect(reportException).toHaveBeenCalled();
|
|
||||||
expect(onException).toHaveBeenCalled();
|
expect(onException).toHaveBeenCalled();
|
||||||
|
|
||||||
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
|
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
|
||||||
expect(reportException.calls.count()).toEqual(1);
|
|
||||||
expect(onException.calls.count()).toEqual(1);
|
expect(onException.calls.count()).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clears the timeout when the done callback is called", function() {
|
it("clears the timeout when the done callback is called", function() {
|
||||||
var queueableFn = { fn: function(done) { done(); } },
|
var queueableFn = { fn: function(done) { done(); } },
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
onComplete = jasmine.createSpy('onComplete'),
|
||||||
reportException = jasmine.createSpy('reportException'),
|
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new j$.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
onComplete: onComplete,
|
onComplete: onComplete,
|
||||||
reportException: reportException,
|
|
||||||
onException: onException
|
onException: onException
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -182,7 +170,6 @@ describe("QueueRunner", function() {
|
|||||||
expect(onComplete).toHaveBeenCalled();
|
expect(onComplete).toHaveBeenCalled();
|
||||||
|
|
||||||
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
|
jasmine.clock().tick(j$.DEFAULT_TIMEOUT_INTERVAL);
|
||||||
expect(reportException).not.toHaveBeenCalled();
|
|
||||||
expect(onException).not.toHaveBeenCalled();
|
expect(onException).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -218,17 +205,14 @@ describe("QueueRunner", function() {
|
|||||||
fn: function() {
|
fn: function() {
|
||||||
throw new Error('fake error');
|
throw new Error('fake error');
|
||||||
} },
|
} },
|
||||||
exceptionCallback = jasmine.createSpy('exception callback'),
|
|
||||||
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
onExceptionCallback = jasmine.createSpy('on exception callback'),
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new j$.QueueRunner({
|
||||||
queueableFns: [queueableFn],
|
queueableFns: [queueableFn],
|
||||||
reportException: exceptionCallback,
|
|
||||||
onException: onExceptionCallback
|
onException: onExceptionCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
expect(exceptionCallback).toHaveBeenCalledWith(jasmine.any(Error), 'queueable');
|
|
||||||
expect(onExceptionCallback).toHaveBeenCalledWith(jasmine.any(Error));
|
expect(onExceptionCallback).toHaveBeenCalledWith(jasmine.any(Error));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -262,7 +262,8 @@ describe("Suite", function() {
|
|||||||
id: suite.id,
|
id: suite.id,
|
||||||
status: '',
|
status: '',
|
||||||
description: "with a child suite",
|
description: "with a child suite",
|
||||||
fullName: "with a child suite"
|
fullName: "with a child suite",
|
||||||
|
failedExpectations: []
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -330,11 +330,29 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
it("reports when an afterAll fails an expectation", function(done) {
|
it("reports when an afterAll fails an expectation", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new j$.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','afterAllEvent']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
expect(reporter.afterAllEvent).toHaveBeenCalledWith('Expectation failed: Expected 1 to equal 2.');
|
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
expect(reporter.afterAllEvent).toHaveBeenCalledWith('Expectation failed: Expected 2 to equal 3.');
|
failedExpectations: [
|
||||||
|
{
|
||||||
|
matcherName : 'toEqual',
|
||||||
|
expected : 2,
|
||||||
|
actual : 1,
|
||||||
|
message : 'Expected 1 to equal 2.',
|
||||||
|
stack: jasmine.any(String),
|
||||||
|
passed: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
matcherName : 'toEqual',
|
||||||
|
expected : 3,
|
||||||
|
actual : 2,
|
||||||
|
message : 'Expected 2 to equal 3.',
|
||||||
|
stack: jasmine.any(String),
|
||||||
|
passed: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -353,46 +371,23 @@ describe("Env integration", function() {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("only reports afterAll expectation failures once, regardless of suite children", function(done) {
|
|
||||||
var env = new j$.Env(),
|
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','afterAllEvent']);
|
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
|
||||||
expect(reporter.afterAllEvent.calls.count()).toEqual(1);
|
|
||||||
expect(reporter.afterAllEvent).toHaveBeenCalledWith('Expectation failed: Expected 1 to equal 2.');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
env.addReporter(reporter);
|
|
||||||
|
|
||||||
env.describe('my suite', function() {
|
|
||||||
env.it('my spec', function() {
|
|
||||||
});
|
|
||||||
|
|
||||||
env.it('my spec2', function() {
|
|
||||||
});
|
|
||||||
|
|
||||||
env.describe('nested suite', function(){
|
|
||||||
env.it('my spec3', function() {
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.afterAll(function() {
|
|
||||||
env.expect(1).toEqual(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.execute();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("reports when afterAll throws an exception", function(done) {
|
it("reports when afterAll throws an exception", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new j$.Env(),
|
||||||
error = new Error('After All Exception'),
|
error = new Error('After All Exception'),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','afterAllEvent']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
expect(reporter.afterAllEvent.calls.count()).toEqual(1);
|
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
expect(reporter.afterAllEvent).toHaveBeenCalledWith('Error thrown: After All Exception');
|
description: 'my suite',
|
||||||
|
failedExpectations: [{
|
||||||
|
matcherName : '',
|
||||||
|
expected : '',
|
||||||
|
actual : '',
|
||||||
|
message : 'Error: After All Exception',
|
||||||
|
stack : jasmine.any(String),
|
||||||
|
passed: false
|
||||||
|
}]
|
||||||
|
}));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -412,10 +407,19 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
it("reports when an async afterAll fails an expectation", function(done) {
|
it("reports when an async afterAll fails an expectation", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new j$.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','afterAllEvent']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
expect(reporter.afterAllEvent).toHaveBeenCalledWith('Expectation failed: Expected 1 to equal 2.');
|
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
failedExpectations: [{
|
||||||
|
matcherName : 'toEqual',
|
||||||
|
expected : 2,
|
||||||
|
actual : 1,
|
||||||
|
message : 'Expected 1 to equal 2.',
|
||||||
|
stack: jasmine.any(String),
|
||||||
|
passed: false
|
||||||
|
}]
|
||||||
|
}));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -437,11 +441,21 @@ describe("Env integration", function() {
|
|||||||
it("reports when an async afterAll throws an exception", function(done) {
|
it("reports when an async afterAll throws an exception", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new j$.Env(),
|
||||||
error = new Error('After All Exception'),
|
error = new Error('After All Exception'),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','afterAllEvent']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
expect(reporter.afterAllEvent).toHaveBeenCalled();
|
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
description: 'my suite',
|
||||||
|
failedExpectations: [{
|
||||||
|
matcherName : '',
|
||||||
|
expected : '',
|
||||||
|
actual : '',
|
||||||
|
message : 'Error: After All Exception',
|
||||||
|
stack : jasmine.any(String),
|
||||||
|
passed: false
|
||||||
|
}]
|
||||||
|
}));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -747,10 +761,19 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
it("should wait the specified interval before reporting an afterAll that fails to call done", function(done) {
|
it("should wait the specified interval before reporting an afterAll that fails to call done", function(done) {
|
||||||
var env = new j$.Env(),
|
var env = new j$.Env(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','afterAllEvent']);
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function() {
|
reporter.jasmineDone.and.callFake(function() {
|
||||||
expect(reporter.afterAllEvent).toHaveBeenCalledWith(jasmine.any(String));
|
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
|
failedExpectations: [{
|
||||||
|
matcherName : '',
|
||||||
|
expected : '',
|
||||||
|
actual : '',
|
||||||
|
message : 'Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.',
|
||||||
|
stack : jasmine.any(String),
|
||||||
|
passed: false
|
||||||
|
}]
|
||||||
|
}));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ describe("New HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when there are afterAllEvents", function () {
|
describe("when there are suite failures", function () {
|
||||||
it("displays the exceptions in their own alert bars", function(){
|
it("displays the exceptions in their own alert bars", function(){
|
||||||
var env = new j$.Env(),
|
var env = new j$.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
@@ -140,15 +140,13 @@ describe("New HtmlReporter", function() {
|
|||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||||
}),
|
});
|
||||||
error = new Error('My After All Exception'),
|
|
||||||
otherError = new Error('My Other Exception');
|
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
reporter.jasmineStarted({});
|
reporter.jasmineStarted({});
|
||||||
reporter.afterAllEvent(error);
|
reporter.suiteDone({ failedExpectations: [{ message: 'My After All Exception' }] });
|
||||||
reporter.afterAllEvent(otherError);
|
reporter.suiteDone({ failedExpectations: [{ message: 'My Other Exception' }] });
|
||||||
reporter.jasmineDone({});
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var alertBars = container.querySelectorAll(".alert .bar");
|
var alertBars = container.querySelectorAll(".alert .bar");
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
yellow: '\x1B[33m',
|
yellow: '\x1B[33m',
|
||||||
none: '\x1B[0m'
|
none: '\x1B[0m'
|
||||||
},
|
},
|
||||||
exceptionList = [];
|
failedSuites = [];
|
||||||
|
|
||||||
this.jasmineStarted = function() {
|
this.jasmineStarted = function() {
|
||||||
specCount = 0;
|
specCount = 0;
|
||||||
@@ -52,10 +52,8 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
||||||
printNewline();
|
printNewline();
|
||||||
|
|
||||||
for(i = 0; i < exceptionList.length; i++) {
|
for(i = 0; i < failedSuites.length; i++) {
|
||||||
printNewline();
|
suiteFailureDetails(failedSuites[i]);
|
||||||
print(colored('red', 'AfterAll ' + exceptionList[i]));
|
|
||||||
printNewline();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onComplete(failureCount === 0);
|
onComplete(failureCount === 0);
|
||||||
@@ -82,9 +80,11 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.afterAllEvent = function(error) {
|
this.suiteDone = function(result) {
|
||||||
failureCount++;
|
if (result.failedExpectations && result.failedExpectations.length > 0) {
|
||||||
exceptionList.push(error);
|
failureCount++;
|
||||||
|
failedSuites.push(result);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -130,6 +130,17 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
|
|
||||||
printNewline();
|
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;
|
return ConsoleReporter;
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
'suiteStarted',
|
'suiteStarted',
|
||||||
'suiteDone',
|
'suiteDone',
|
||||||
'specStarted',
|
'specStarted',
|
||||||
'specDone',
|
'specDone'
|
||||||
'afterAllEvent'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.specFilter = function() {
|
this.specFilter = function() {
|
||||||
@@ -171,11 +170,6 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
options.catchException = catchException;
|
options.catchException = catchException;
|
||||||
options.clearStack = options.clearStack || clearStack;
|
options.clearStack = options.clearStack || clearStack;
|
||||||
options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
|
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();
|
new j$.QueueRunner(options).execute();
|
||||||
};
|
};
|
||||||
@@ -185,8 +179,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
id: getNextSuiteId(),
|
id: getNextSuiteId(),
|
||||||
description: 'Jasmine__TopLevel__Suite',
|
description: 'Jasmine__TopLevel__Suite',
|
||||||
queueRunner: queueRunnerFactory,
|
queueRunner: queueRunnerFactory,
|
||||||
resultCallback: function() {}, // TODO - hook this up
|
resultCallback: function(attrs) {
|
||||||
reportExpectationFailure: reportExpectationFailure
|
reporter.suiteDone(attrs);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
runnableLookupTable[topSuite.id] = topSuite;
|
runnableLookupTable[topSuite.id] = topSuite;
|
||||||
defaultResourcesForRunnable(topSuite.id);
|
defaultResourcesForRunnable(topSuite.id);
|
||||||
@@ -243,14 +238,14 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
queueRunner: queueRunnerFactory,
|
queueRunner: queueRunnerFactory,
|
||||||
onStart: suiteStarted,
|
onStart: suiteStarted,
|
||||||
expectationFactory: expectationFactory,
|
expectationFactory: expectationFactory,
|
||||||
|
expectationResultFactory: expectationResultFactory,
|
||||||
resultCallback: function(attrs) {
|
resultCallback: function(attrs) {
|
||||||
if (!suite.disabled) {
|
if (!suite.disabled) {
|
||||||
clearResourcesForRunnable(suite.id);
|
clearResourcesForRunnable(suite.id);
|
||||||
currentlyExecutingSuites.pop();
|
currentlyExecutingSuites.pop();
|
||||||
}
|
}
|
||||||
reporter.suiteDone(attrs);
|
reporter.suiteDone(attrs);
|
||||||
},
|
}
|
||||||
reportExpectationFailure: reportExpectationFailure
|
|
||||||
});
|
});
|
||||||
|
|
||||||
runnableLookupTable[suite.id] = suite;
|
runnableLookupTable[suite.id] = suite;
|
||||||
@@ -330,7 +325,6 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
id: getNextSpecId(),
|
id: getNextSpecId(),
|
||||||
beforeAndAfterFns: beforeAndAfterFns(suite, runnablesExplictlySetGetter),
|
beforeAndAfterFns: beforeAndAfterFns(suite, runnablesExplictlySetGetter),
|
||||||
expectationFactory: expectationFactory,
|
expectationFactory: expectationFactory,
|
||||||
exceptionFormatter: exceptionFormatter,
|
|
||||||
resultCallback: specResultCallback,
|
resultCallback: specResultCallback,
|
||||||
getSpecName: function(spec) {
|
getSpecName: function(spec) {
|
||||||
return getSpecName(spec, suite);
|
return getSpecName(spec, suite);
|
||||||
@@ -410,10 +404,6 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
this.pending = function() {
|
this.pending = function() {
|
||||||
throw j$.Spec.pendingSpecExceptionMessage;
|
throw j$.Spec.pendingSpecExceptionMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
function reportExpectationFailure(message) {
|
|
||||||
reporter.afterAllEvent('Expectation failed: '+ message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Env;
|
return Env;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
this.catchException = attrs.catchException || function() { return true; };
|
this.catchException = attrs.catchException || function() { return true; };
|
||||||
this.userContext = attrs.userContext || {};
|
this.userContext = attrs.userContext || {};
|
||||||
this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
|
this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
|
||||||
this.reportException = attrs.reportException || function() {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueRunner.prototype.execute = function() {
|
QueueRunner.prototype.execute = function() {
|
||||||
@@ -81,7 +80,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onException(e, queueableFn) {
|
function onException(e, queueableFn) {
|
||||||
self.reportException(e, queueableFn.type);
|
|
||||||
self.onException(e);
|
self.onException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
this.beforeAndAfterFns = attrs.beforeAndAfterFns || function() { return {befores: [], afters: []}; };
|
this.beforeAndAfterFns = attrs.beforeAndAfterFns || function() { return {befores: [], afters: []}; };
|
||||||
this.userContext = attrs.userContext || function() { return {}; };
|
this.userContext = attrs.userContext || function() { return {}; };
|
||||||
this.onStart = attrs.onStart || function() {};
|
this.onStart = attrs.onStart || function() {};
|
||||||
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
|
|
||||||
this.getSpecName = attrs.getSpecName || function() { return ''; };
|
this.getSpecName = attrs.getSpecName || function() { return ''; };
|
||||||
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
||||||
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
this.resultCallback = attrs.resultCallback || function() {};
|
this.resultCallback = attrs.resultCallback || function() {};
|
||||||
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
this.clearStack = attrs.clearStack || function(fn) {fn();};
|
||||||
this.expectationFactory = attrs.expectationFactory;
|
this.expectationFactory = attrs.expectationFactory;
|
||||||
this.reportExpectationFailure = attrs.reportExpectationFailure || function() {};
|
this.expectationResultFactory = attrs.expectationResultFactory;
|
||||||
|
|
||||||
this.beforeFns = [];
|
this.beforeFns = [];
|
||||||
this.afterFns = [];
|
this.afterFns = [];
|
||||||
@@ -23,7 +23,8 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
id: this.id,
|
id: this.id,
|
||||||
status: this.disabled ? 'disabled' : '',
|
status: this.disabled ? 'disabled' : '',
|
||||||
description: this.description,
|
description: this.description,
|
||||||
fullName: this.getFullName()
|
fullName: this.getFullName(),
|
||||||
|
failedExpectations: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,31 +131,43 @@ getJasmineRequireObj().Suite = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Suite.prototype.onException = function() {
|
Suite.prototype.onException = function() {
|
||||||
for (var i = 0; i < this.children.length; i++) {
|
if(isAfterAll(this.children)) {
|
||||||
var child = this.children[i];
|
var data = {
|
||||||
child.onException.apply(child, arguments);
|
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 () {
|
Suite.prototype.addExpectationResult = function () {
|
||||||
if(isAfterAll(this.children) && isFailure(arguments)){
|
if(isAfterAll(this.children) && isFailure(arguments)){
|
||||||
this.reportExpectationFailure(arguments[1].message);
|
var data = arguments[1];
|
||||||
|
this.result.failedExpectations.push(this.expectationResultFactory(data));
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < this.children.length; i++) {
|
for (var i = 0; i < this.children.length; i++) {
|
||||||
var child = this.children[i];
|
var child = this.children[i];
|
||||||
child.addExpectationResult.apply(child, arguments);
|
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) {
|
function clone(obj) {
|
||||||
var clonedObj = {};
|
var clonedObj = {};
|
||||||
for (var prop in obj) {
|
for (var prop in obj) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
pendingSpecCount = 0,
|
pendingSpecCount = 0,
|
||||||
htmlReporterMain,
|
htmlReporterMain,
|
||||||
symbols,
|
symbols,
|
||||||
exceptionList = [];
|
failedSuites = [];
|
||||||
|
|
||||||
this.initialize = function() {
|
this.initialize = function() {
|
||||||
htmlReporterMain = createDom('div', {className: 'html-reporter'},
|
htmlReporterMain = createDom('div', {className: 'html-reporter'},
|
||||||
@@ -54,6 +54,10 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.suiteDone = function(result) {
|
this.suiteDone = function(result) {
|
||||||
|
if (result.failedExpectations && result.failedExpectations.length > 0) {
|
||||||
|
failedSuites.push(result);
|
||||||
|
}
|
||||||
|
|
||||||
if (currentParent == topResults) {
|
if (currentParent == topResults) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -65,10 +69,6 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
currentParent.addChild(result, 'spec');
|
currentParent.addChild(result, 'spec');
|
||||||
};
|
};
|
||||||
|
|
||||||
this.afterAllEvent = function(error) {
|
|
||||||
exceptionList.push(error);
|
|
||||||
};
|
|
||||||
|
|
||||||
var failures = [];
|
var failures = [];
|
||||||
this.specDone = function(result) {
|
this.specDone = function(result) {
|
||||||
if (result.status != 'disabled') {
|
if (result.status != 'disabled') {
|
||||||
@@ -141,10 +141,13 @@ 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));
|
||||||
|
|
||||||
for(i = 0; i < exceptionList.length; i++) {
|
for(i = 0; i < failedSuites.length; i++) {
|
||||||
var errorBarMessage = 'AfterAll ' + (exceptionList[i]);
|
var failedSuite = failedSuites[i];
|
||||||
var errorBarClassName = 'bar errored';
|
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
|
||||||
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
|
var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
|
||||||
|
var errorBarClassName = 'bar errored';
|
||||||
|
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = find('.results');
|
var results = find('.results');
|
||||||
|
|||||||
Reference in New Issue
Block a user