Merge branch 'dtychshenko-1740-fail-on-no-expectations'

* Merges #1743 from @dtychshenko
* Fixes #1740
This commit is contained in:
Steve Gravrock
2019-09-05 09:48:24 -07:00
11 changed files with 229 additions and 64 deletions

View File

@@ -141,12 +141,13 @@ jasmineRequire.HtmlReporter = function(j$) {
this.specDone = function(result) {
stateBuilder.specDone(result);
if (
noExpectations(result) &&
typeof console !== 'undefined' &&
typeof console.error !== 'undefined'
) {
console.warn("Spec '" + result.fullName + "' has no expectations.");
if (noExpectations(result)) {
var noSpecMsg = "Spec '" + result.fullName + "' has no expectations.";
if (result.status === 'failed') {
console.error(noSpecMsg);
} else {
console.warn(noSpecMsg);
}
}
if (!symbols) {
@@ -169,7 +170,7 @@ jasmineRequire.HtmlReporter = function(j$) {
};
this.displaySpecInCorrectFormat = function(result) {
return noExpectations(result)
return noExpectations(result) && result.status === 'passed'
? 'jasmine-empty'
: this.resultStatus(result.status);
};
@@ -392,6 +393,16 @@ jasmineRequire.HtmlReporter = function(j$) {
);
}
if (result.failedExpectations.length === 0) {
messages.appendChild(
createDom(
'div',
{ className: 'jasmine-result-message' },
'Spec has no expectations'
)
);
}
return failure;
}
@@ -683,9 +694,12 @@ jasmineRequire.HtmlReporter = function(j$) {
}
function noExpectations(result) {
var allExpectations =
result.failedExpectations.length + result.passedExpectations.length;
return (
result.failedExpectations.length + result.passedExpectations.length ===
0 && result.status === 'passed'
allExpectations === 0 &&
(result.status === 'passed' || result.status === 'failed')
);
}