Allow pending to take a reason and show it in the HtmlReporter
[#78954014] Fix #671
This commit is contained in:
@@ -430,8 +430,12 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
});
|
||||
};
|
||||
|
||||
this.pending = function() {
|
||||
throw j$.Spec.pendingSpecExceptionMessage;
|
||||
this.pending = function(message) {
|
||||
var fullMessage = j$.Spec.pendingSpecExceptionMessage;
|
||||
if(message) {
|
||||
fullMessage += message;
|
||||
}
|
||||
throw fullMessage;
|
||||
};
|
||||
|
||||
this.fail = function(error) {
|
||||
|
||||
@@ -22,7 +22,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: [],
|
||||
passedExpectations: []
|
||||
passedExpectations: [],
|
||||
pendingReason: ''
|
||||
};
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
|
||||
Spec.prototype.onException = function onException(e) {
|
||||
if (Spec.isPendingSpecException(e)) {
|
||||
this.pend();
|
||||
this.pend(extractCustomPendingMessage(e));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,8 +89,11 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.disabled = true;
|
||||
};
|
||||
|
||||
Spec.prototype.pend = function() {
|
||||
Spec.prototype.pend = function(message) {
|
||||
this.markedPending = true;
|
||||
if (message) {
|
||||
this.result.pendingReason = message;
|
||||
}
|
||||
};
|
||||
|
||||
Spec.prototype.status = function() {
|
||||
@@ -116,6 +120,14 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return this.getSpecName(this);
|
||||
};
|
||||
|
||||
var extractCustomPendingMessage = function(e) {
|
||||
var fullMessage = e.toString(),
|
||||
boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage),
|
||||
boilerplateEnd = boilerplateStart + Spec.pendingSpecExceptionMessage.length;
|
||||
|
||||
return fullMessage.substr(boilerplateEnd);
|
||||
};
|
||||
|
||||
Spec.pendingSpecExceptionMessage = '=> marked Pending';
|
||||
|
||||
Spec.isPendingSpecException = function(e) {
|
||||
|
||||
@@ -45,7 +45,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
||||
},
|
||||
|
||||
pending: function() {
|
||||
return env.pending();
|
||||
return env.pending.apply(env, arguments);
|
||||
},
|
||||
|
||||
fail: function() {
|
||||
|
||||
@@ -192,6 +192,9 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
if(noExpectations(resultNode.result)) {
|
||||
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
|
||||
}
|
||||
if(resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') {
|
||||
specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason;
|
||||
}
|
||||
specListNode.appendChild(
|
||||
createDom('li', {
|
||||
className: resultNode.result.status,
|
||||
|
||||
Reference in New Issue
Block a user