Adds new configuration option to failSpecWithNoExpectations that will report specs without expectations as failures if enabled

This commit is contained in:
Dmitriy T
2019-08-22 16:08:43 -04:00
committed by Steve Gravrock
parent e8870db8d3
commit 7263a38c3f
9 changed files with 172 additions and 48 deletions

View File

@@ -82,7 +82,7 @@ getJasmineRequireObj().Spec = function(j$) {
return this.asyncExpectationFactory(actual, this);
};
Spec.prototype.execute = function(onComplete, excluded) {
Spec.prototype.execute = function(onComplete, excluded, failSpecWithNoExp) {
var self = this;
var onStart = {
@@ -95,7 +95,7 @@ getJasmineRequireObj().Spec = function(j$) {
var complete = {
fn: function(done) {
self.queueableFn.fn = null;
self.result.status = self.status(excluded);
self.result.status = self.status(excluded, failSpecWithNoExp);
self.resultCallback(self.result, done);
}
};
@@ -166,7 +166,7 @@ getJasmineRequireObj().Spec = function(j$) {
return this.result;
};
Spec.prototype.status = function(excluded) {
Spec.prototype.status = function(excluded, failSpecWithNoExpectations) {
if (excluded === true) {
return 'excluded';
}
@@ -175,11 +175,17 @@ getJasmineRequireObj().Spec = function(j$) {
return 'pending';
}
if (this.result.failedExpectations.length > 0) {
if (
this.result.failedExpectations.length > 0 ||
(failSpecWithNoExpectations &&
this.result.failedExpectations.length +
this.result.passedExpectations.length ===
0)
) {
return 'failed';
} else {
return 'passed';
}
return 'passed';
};
Spec.prototype.getFullName = function() {