afterEach now allows for waits, runs blocks
This commit is contained in:
27
src/Spec.js
27
src/Spec.js
@@ -100,7 +100,6 @@ jasmine.Spec.prototype.finish = function(onComplete) {
|
||||
for (var i = 0; i < this.afterCallbacks.length; i++) {
|
||||
this.afterCallbacks[i]();
|
||||
}
|
||||
this.safeExecuteAfters();
|
||||
this.removeAllSpies();
|
||||
this.finishCallback();
|
||||
if (onComplete) {
|
||||
@@ -112,7 +111,6 @@ jasmine.Spec.prototype.after = function(doAfter) {
|
||||
this.afterCallbacks.unshift(doAfter);
|
||||
};
|
||||
|
||||
|
||||
jasmine.Spec.prototype.execute = function(onComplete) {
|
||||
var spec = this;
|
||||
if (!spec.env.specFilter(spec)) {
|
||||
@@ -125,7 +123,7 @@ jasmine.Spec.prototype.execute = function(onComplete) {
|
||||
spec.env.currentSpec = spec;
|
||||
spec.env.currentlyRunningTests = true;
|
||||
|
||||
spec.safeExecuteBefores();
|
||||
spec.addBeforesAndAftersToQueue();
|
||||
|
||||
spec.queue.start(function () {
|
||||
spec.finish(onComplete);
|
||||
@@ -133,34 +131,17 @@ jasmine.Spec.prototype.execute = function(onComplete) {
|
||||
spec.env.currentlyRunningTests = false;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.safeExecuteBefores = function() {
|
||||
jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
|
||||
for (var suite = this.suite; suite; suite = suite.parentSuite) {
|
||||
if (suite.beforeQueue) {
|
||||
for (var i = 0; i < suite.beforeQueue.length; i++)
|
||||
this.queue.addBefore(new jasmine.Block(this.env, suite.beforeQueue[i], this));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.safeExecuteAfters = function() {
|
||||
var afters = [];
|
||||
for (var suite = this.suite; suite; suite = suite.parentSuite) {
|
||||
if (suite.afterQueue) {
|
||||
for (var i = 0; i < suite.afterQueue.length; i++)
|
||||
afters.unshift(suite.afterQueue[i]);
|
||||
for (var j = 0; j < suite.afterQueue.length; j++)
|
||||
this.queue.add(new jasmine.Block(this.env, suite.afterQueue[j], this));
|
||||
}
|
||||
}
|
||||
while (afters.length) {
|
||||
this.safeExecuteBeforeOrAfter(afters.pop());
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.safeExecuteBeforeOrAfter = function(func) {
|
||||
try {
|
||||
func.apply(this);
|
||||
} catch (e) {
|
||||
this.results.addResult(new jasmine.ExpectationResult(false, func.typeName + '() fail: ' + jasmine.util.formatException(e), null));
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.explodes = function() {
|
||||
|
||||
Reference in New Issue
Block a user