Allow user to stop a specs execution when an expectation fails

[finish #1165916] #577
This commit is contained in:
Gregg Van Hove and Molly Trombley-McCann
2015-03-05 15:28:00 -08:00
parent 1a08d1e8c6
commit 7693a4c959
16 changed files with 461 additions and 47 deletions

View File

@@ -12,6 +12,7 @@ getJasmineRequireObj().Spec = function(j$) {
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
if (!this.queueableFn.fn) {
this.pend();
@@ -33,6 +34,10 @@ getJasmineRequireObj().Spec = function(j$) {
this.result.passedExpectations.push(expectationResult);
} else {
this.result.failedExpectations.push(expectationResult);
if(this.throwOnExpectationFailure){
throw new j$.errors.ExpectationFailed();
}
}
};
@@ -76,6 +81,10 @@ getJasmineRequireObj().Spec = function(j$) {
return;
}
if (e instanceof j$.errors.ExpectationFailed) {
return;
}
this.addExpectationResult(false, {
matcherName: '',
passed: false,