karma-jasmine-html-reporter
Advanced tools
Comparing version 1.4.2 to 1.5.0
{ | ||
"name": "karma-jasmine-html-reporter", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"description": "A Karma plugin. Dynamically displays tests results at debug.html page", | ||
@@ -43,3 +43,3 @@ "main": "./src/index.js", | ||
"karma-jasmine": ">=1.1", | ||
"jasmine-core": ">=3.3" | ||
"jasmine-core": ">=3.5" | ||
}, | ||
@@ -49,5 +49,5 @@ "license": "MIT", | ||
"chalk": "*", | ||
"jasmine-core": ">=3.3" | ||
"jasmine-core": ">=3.5" | ||
}, | ||
"readmeFilename": "README.md" | ||
} |
@@ -67,3 +67,3 @@ (function (window) { | ||
var specFilter; | ||
if (queryString.getParam("spec")) { | ||
if (!config.specFilter || queryString.getParam("spec")) { | ||
specFilter = new jasmine.HtmlSpecFilter({ | ||
@@ -70,0 +70,0 @@ filterString: function () { return queryString.getParam("spec"); } |
/* | ||
Copyright (c) 2008-2018 Pivotal Labs | ||
Copyright (c) 2008-2019 Pivotal Labs | ||
@@ -31,8 +31,2 @@ Permission is hereby granted, free of charge, to any person obtaining | ||
jasmineRequire.HtmlReporter = function (j$) { | ||
var noopTimer = { | ||
start: function () { }, | ||
elapsed: function () { return 0; } | ||
}; | ||
function ResultsStateBuilder() { | ||
@@ -62,4 +56,3 @@ this.topResults = new j$.ResultsNode({}, '', null); | ||
ResultsStateBuilder.prototype.specStarted = function (result) { | ||
}; | ||
ResultsStateBuilder.prototype.specStarted = function (result) { }; | ||
@@ -82,6 +75,6 @@ ResultsStateBuilder.prototype.specDone = function (result) { | ||
function HtmlReporter(options) { | ||
var config = function () { return (options.env && options.env.configuration()) || {}; }, | ||
var config = function () { | ||
return (options.env && options.env.configuration()) || {}; | ||
}, | ||
getContainer = options.getContainer, | ||
@@ -91,5 +84,5 @@ createElement = options.createElement, | ||
navigateWithNewParam = options.navigateWithNewParam || function () { }, | ||
addToExistingQueryString = options.addToExistingQueryString || defaultQueryString, | ||
addToExistingQueryString = | ||
options.addToExistingQueryString || defaultQueryString, | ||
filterSpecs = options.filterSpecs, | ||
timer = options.timer || noopTimer, | ||
htmlReporterMain, | ||
@@ -101,5 +94,13 @@ symbols, | ||
clearPrior(); | ||
htmlReporterMain = createDom('div', { className: 'jasmine_html-reporter' }, | ||
createDom('div', { className: 'jasmine-banner' }, | ||
createDom('a', { className: 'jasmine-title', href: 'http://jasmine.github.io/', target: '_blank' }), | ||
htmlReporterMain = createDom( | ||
'div', | ||
{ className: 'jasmine_html-reporter' }, | ||
createDom( | ||
'div', | ||
{ className: 'jasmine-banner' }, | ||
createDom('a', { | ||
className: 'jasmine-title', | ||
href: 'http://jasmine.github.io/', | ||
target: '_blank' | ||
}), | ||
createDom('span', { className: 'jasmine-version' }, j$.version) | ||
@@ -109,3 +110,5 @@ ), | ||
createDom('div', { className: 'jasmine-alert' }), | ||
createDom('div', { className: 'jasmine-results' }, | ||
createDom( | ||
'div', | ||
{ className: 'jasmine-results' }, | ||
createDom('div', { className: 'jasmine-failures' }) | ||
@@ -120,3 +123,2 @@ ) | ||
totalSpecsDefined = options.totalSpecsDefined || 0; | ||
timer.start(); | ||
}; | ||
@@ -149,4 +151,9 @@ | ||
if (noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') { | ||
console.error('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); | ||
} | ||
} | ||
@@ -158,8 +165,9 @@ | ||
symbols.appendChild(createDom('li', { | ||
className: this.displaySpecInCorrectFormat(result), | ||
id: 'spec_' + result.id, | ||
title: result.fullName | ||
} | ||
)); | ||
symbols.appendChild( | ||
createDom('li', { | ||
className: this.displaySpecInCorrectFormat(result), | ||
id: 'spec_' + result.id, | ||
title: result.fullName | ||
}) | ||
); | ||
@@ -174,3 +182,5 @@ if (result.status === 'failed') { | ||
this.displaySpecInCorrectFormat = function (result) { | ||
return noExpectations(result) ? 'jasmine-empty' : this.resultStatus(result.status); | ||
return noExpectations(result) && result.status === 'passed' | ||
? 'jasmine-empty' | ||
: this.resultStatus(result.status); | ||
}; | ||
@@ -180,3 +190,5 @@ | ||
if (status === 'excluded') { | ||
return config().hideDisabled ? 'jasmine-excluded-no-display' : 'jasmine-excluded'; | ||
return config().hideDisabled | ||
? 'jasmine-excluded-no-display' | ||
: 'jasmine-excluded'; | ||
} | ||
@@ -191,3 +203,9 @@ return 'jasmine-' + status; | ||
var i; | ||
alert.appendChild(createDom('span', { className: 'jasmine-duration' }, 'finished in ' + timer.elapsed() / 1000 + 's')); | ||
alert.appendChild( | ||
createDom( | ||
'span', | ||
{ className: 'jasmine-duration' }, | ||
'finished in ' + doneResult.totalTime / 1000 + 's' | ||
) | ||
); | ||
@@ -197,7 +215,18 @@ banner.appendChild(optionsMenu(config())); | ||
if (stateBuilder.specsExecuted < totalSpecsDefined) { | ||
var skippedMessage = 'Ran ' + stateBuilder.specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all'; | ||
var skippedMessage = | ||
'Ran ' + | ||
stateBuilder.specsExecuted + | ||
' of ' + | ||
totalSpecsDefined + | ||
' specs - run all'; | ||
var skippedLink = addToExistingQueryString('spec', ''); | ||
alert.appendChild( | ||
createDom('span', { className: 'jasmine-bar jasmine-skipped' }, | ||
createDom('a', { href: skippedLink, title: 'Run all specs' }, skippedMessage) | ||
createDom( | ||
'span', | ||
{ className: 'jasmine-bar jasmine-skipped' }, | ||
createDom( | ||
'a', | ||
{ href: skippedLink, title: 'Run all specs' }, | ||
skippedMessage | ||
) | ||
) | ||
@@ -212,4 +241,10 @@ ); | ||
if (totalSpecsDefined > 0 || failed) { | ||
statusBarMessage += pluralize('spec', stateBuilder.specsExecuted) + ', ' + pluralize('failure', stateBuilder.failureCount); | ||
if (stateBuilder.pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', stateBuilder.pendingSpecCount); } | ||
statusBarMessage += | ||
pluralize('spec', stateBuilder.specsExecuted) + | ||
', ' + | ||
pluralize('failure', stateBuilder.failureCount); | ||
if (stateBuilder.pendingSpecCount) { | ||
statusBarMessage += | ||
', ' + pluralize('pending spec', stateBuilder.pendingSpecCount); | ||
} | ||
} | ||
@@ -221,3 +256,7 @@ | ||
statusBarClassName += ' jasmine-incomplete '; | ||
statusBarMessage = 'Incomplete: ' + doneResult.incompleteReason + ', ' + statusBarMessage; | ||
statusBarMessage = | ||
'Incomplete: ' + | ||
doneResult.incompleteReason + | ||
', ' + | ||
statusBarMessage; | ||
} else { | ||
@@ -229,9 +268,25 @@ statusBarClassName += ' jasmine-failed '; | ||
if (order && order.random) { | ||
seedBar = createDom('span', { className: 'jasmine-seed-bar' }, | ||
seedBar = createDom( | ||
'span', | ||
{ className: 'jasmine-seed-bar' }, | ||
', randomized with seed ', | ||
createDom('a', { title: 'randomized with seed ' + order.seed, href: seedHref(order.seed) }, order.seed) | ||
createDom( | ||
'a', | ||
{ | ||
title: 'randomized with seed ' + order.seed, | ||
href: seedHref(order.seed) | ||
}, | ||
order.seed | ||
) | ||
); | ||
} | ||
alert.appendChild(createDom('span', { className: statusBarClassName }, statusBarMessage, seedBar)); | ||
alert.appendChild( | ||
createDom( | ||
'span', | ||
{ className: statusBarClassName }, | ||
statusBarMessage, | ||
seedBar | ||
) | ||
); | ||
@@ -242,3 +297,9 @@ var errorBarClassName = 'jasmine-bar jasmine-errored'; | ||
for (i = 0; i < globalFailures.length; i++) { | ||
alert.appendChild(createDom('span', { className: errorBarClassName }, globalFailureMessage(globalFailures[i]))); | ||
alert.appendChild( | ||
createDom( | ||
'span', | ||
{ className: errorBarClassName }, | ||
globalFailureMessage(globalFailures[i]) | ||
) | ||
); | ||
} | ||
@@ -251,3 +312,5 @@ | ||
if (failure.filename) { | ||
return prefix + ' in ' + failure.filename + ' line ' + failure.lineno; | ||
return ( | ||
prefix + ' in ' + failure.filename + ' line ' + failure.lineno | ||
); | ||
} else { | ||
@@ -266,3 +329,9 @@ return prefix; | ||
var warning = deprecationWarnings[i]; | ||
alert.appendChild(createDom('span', { className: warningBarClassName }, 'DEPRECATION: ' + warning)); | ||
alert.appendChild( | ||
createDom( | ||
'span', | ||
{ className: warningBarClassName }, | ||
'DEPRECATION: ' + warning | ||
) | ||
); | ||
} | ||
@@ -277,9 +346,25 @@ | ||
alert.appendChild( | ||
createDom('span', { className: 'jasmine-menu jasmine-bar jasmine-spec-list' }, | ||
createDom( | ||
'span', | ||
{ className: 'jasmine-menu jasmine-bar jasmine-spec-list' }, | ||
createDom('span', {}, 'Spec List | '), | ||
createDom('a', { className: 'jasmine-failures-menu', href: '#' }, 'Failures'))); | ||
createDom( | ||
'a', | ||
{ className: 'jasmine-failures-menu', href: '#' }, | ||
'Failures' | ||
) | ||
) | ||
); | ||
alert.appendChild( | ||
createDom('span', { className: 'jasmine-menu jasmine-bar jasmine-failure-list' }, | ||
createDom('a', { className: 'jasmine-spec-list-menu', href: '#' }, 'Spec List'), | ||
createDom('span', {}, ' | Failures '))); | ||
createDom( | ||
'span', | ||
{ className: 'jasmine-menu jasmine-bar jasmine-failure-list' }, | ||
createDom( | ||
'a', | ||
{ className: 'jasmine-spec-list-menu', href: '#' }, | ||
'Spec List' | ||
), | ||
createDom('span', {}, ' | Failures ') | ||
) | ||
); | ||
@@ -305,7 +390,8 @@ find('.jasmine-failures-menu').onclick = function () { | ||
function failureDom(result) { | ||
var failure = | ||
createDom('div', { className: 'jasmine-spec-detail jasmine-failed' }, | ||
failureDescription(result, stateBuilder.currentParent), | ||
createDom('div', { className: 'jasmine-messages' }) | ||
); | ||
var failure = createDom( | ||
'div', | ||
{ className: 'jasmine-spec-detail jasmine-failed' }, | ||
failureDescription(result, stateBuilder.currentParent), | ||
createDom('div', { className: 'jasmine-messages' }) | ||
); | ||
var messages = failure.childNodes[1]; | ||
@@ -315,6 +401,28 @@ | ||
var expectation = result.failedExpectations[i]; | ||
messages.appendChild(createDom('div', { className: 'jasmine-result-message' }, expectation.message)); | ||
messages.appendChild(createDom('div', { className: 'jasmine-stack-trace' }, expectation.stack)); | ||
messages.appendChild( | ||
createDom( | ||
'div', | ||
{ className: 'jasmine-result-message' }, | ||
expectation.message | ||
) | ||
); | ||
messages.appendChild( | ||
createDom( | ||
'div', | ||
{ className: 'jasmine-stack-trace' }, | ||
expectation.stack | ||
) | ||
); | ||
} | ||
if (result.failedExpectations.length === 0) { | ||
messages.appendChild( | ||
createDom( | ||
'div', | ||
{ className: 'jasmine-result-message' }, | ||
'Spec has no expectations' | ||
) | ||
); | ||
} | ||
return failure; | ||
@@ -331,5 +439,16 @@ } | ||
if (resultNode.type === 'suite') { | ||
var suiteListNode = createDom('ul', { className: 'jasmine-suite', id: 'suite-' + resultNode.result.id }, | ||
createDom('li', { className: 'jasmine-suite-detail jasmine-' + resultNode.result.status }, | ||
createDom('a', { href: specHref(resultNode.result) }, resultNode.result.description) | ||
var suiteListNode = createDom( | ||
'ul', | ||
{ className: 'jasmine-suite', id: 'suite-' + resultNode.result.id }, | ||
createDom( | ||
'li', | ||
{ | ||
className: | ||
'jasmine-suite-detail jasmine-' + resultNode.result.status | ||
}, | ||
createDom( | ||
'a', | ||
{ href: specHref(resultNode.result) }, | ||
resultNode.result.description | ||
) | ||
) | ||
@@ -350,11 +469,23 @@ ); | ||
} | ||
if (resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') { | ||
specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason; | ||
if ( | ||
resultNode.result.status === 'pending' && | ||
resultNode.result.pendingReason !== '' | ||
) { | ||
specDescription = | ||
specDescription + | ||
' PENDING WITH MESSAGE: ' + | ||
resultNode.result.pendingReason; | ||
} | ||
specListNode.appendChild( | ||
createDom('li', { | ||
className: 'jasmine-' + resultNode.result.status, | ||
id: 'spec-' + resultNode.result.id | ||
}, | ||
createDom('a', { href: specHref(resultNode.result) }, specDescription) | ||
createDom( | ||
'li', | ||
{ | ||
className: 'jasmine-' + resultNode.result.status, | ||
id: 'spec-' + resultNode.result.id | ||
}, | ||
createDom( | ||
'a', | ||
{ href: specHref(resultNode.result) }, | ||
specDescription | ||
) | ||
) | ||
@@ -367,6 +498,12 @@ ); | ||
function optionsMenu(config) { | ||
var optionsMenuDom = createDom('div', { className: 'jasmine-run-options' }, | ||
var optionsMenuDom = createDom( | ||
'div', | ||
{ className: 'jasmine-run-options' }, | ||
createDom('span', { className: 'jasmine-trigger' }, 'Options'), | ||
createDom('div', { className: 'jasmine-payload' }, | ||
createDom('div', { className: 'jasmine-stop-on-failure' }, | ||
createDom( | ||
'div', | ||
{ className: 'jasmine-payload' }, | ||
createDom( | ||
'div', | ||
{ className: 'jasmine-stop-on-failure' }, | ||
createDom('input', { | ||
@@ -377,4 +514,11 @@ className: 'jasmine-fail-fast', | ||
}), | ||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-fail-fast' }, 'stop execution on spec failure')), | ||
createDom('div', { className: 'jasmine-throw-failures' }, | ||
createDom( | ||
'label', | ||
{ className: 'jasmine-label', for: 'jasmine-fail-fast' }, | ||
'stop execution on spec failure' | ||
) | ||
), | ||
createDom( | ||
'div', | ||
{ className: 'jasmine-throw-failures' }, | ||
createDom('input', { | ||
@@ -385,4 +529,11 @@ className: 'jasmine-throw', | ||
}), | ||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-throw-failures' }, 'stop spec on expectation failure')), | ||
createDom('div', { className: 'jasmine-random-order' }, | ||
createDom( | ||
'label', | ||
{ className: 'jasmine-label', for: 'jasmine-throw-failures' }, | ||
'stop spec on expectation failure' | ||
) | ||
), | ||
createDom( | ||
'div', | ||
{ className: 'jasmine-random-order' }, | ||
createDom('input', { | ||
@@ -393,4 +544,11 @@ className: 'jasmine-random', | ||
}), | ||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order')), | ||
createDom('div', { className: 'jasmine-hide-disabled' }, | ||
createDom( | ||
'label', | ||
{ className: 'jasmine-label', for: 'jasmine-random-order' }, | ||
'run tests in random order' | ||
) | ||
), | ||
createDom( | ||
'div', | ||
{ className: 'jasmine-hide-disabled' }, | ||
createDom('input', { | ||
@@ -401,3 +559,8 @@ className: 'jasmine-disabled', | ||
}), | ||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-hide-disabled' }, 'hide disabled tests')) | ||
createDom( | ||
'label', | ||
{ className: 'jasmine-label', for: 'jasmine-hide-disabled' }, | ||
'hide disabled tests' | ||
) | ||
) | ||
) | ||
@@ -412,3 +575,5 @@ ); | ||
var throwCheckbox = optionsMenuDom.querySelector('#jasmine-throw-failures'); | ||
var throwCheckbox = optionsMenuDom.querySelector( | ||
'#jasmine-throw-failures' | ||
); | ||
throwCheckbox.checked = config.oneFailurePerSpec; | ||
@@ -419,3 +584,5 @@ throwCheckbox.onclick = function () { | ||
var randomCheckbox = optionsMenuDom.querySelector('#jasmine-random-order'); | ||
var randomCheckbox = optionsMenuDom.querySelector( | ||
'#jasmine-random-order' | ||
); | ||
randomCheckbox.checked = config.random; | ||
@@ -438,3 +605,6 @@ randomCheckbox.onclick = function () { | ||
if (isOpen.test(optionsPayload.className)) { | ||
optionsPayload.className = optionsPayload.className.replace(isOpen, ''); | ||
optionsPayload.className = optionsPayload.className.replace( | ||
isOpen, | ||
'' | ||
); | ||
} else { | ||
@@ -449,4 +619,10 @@ optionsPayload.className += ' jasmine-open'; | ||
function failureDescription(result, suite) { | ||
var wrapper = createDom('div', { className: 'jasmine-description' }, | ||
createDom('a', { title: result.description, href: specHref(result) }, result.description) | ||
var wrapper = createDom( | ||
'div', | ||
{ className: 'jasmine-description' }, | ||
createDom( | ||
'a', | ||
{ title: result.description, href: specHref(result) }, | ||
result.description | ||
) | ||
); | ||
@@ -457,3 +633,7 @@ var suiteLink; | ||
wrapper.insertBefore(createTextNode(' > '), wrapper.firstChild); | ||
suiteLink = createDom('a', { href: suiteHref(suite) }, suite.result.description); | ||
suiteLink = createDom( | ||
'a', | ||
{ href: suiteHref(suite) }, | ||
suite.result.description | ||
); | ||
wrapper.insertBefore(suiteLink, wrapper.firstChild); | ||
@@ -529,3 +709,3 @@ | ||
function pluralize(singular, count) { | ||
var word = (count == 1 ? singular : singular + 's'); | ||
var word = count == 1 ? singular : singular + 's'; | ||
@@ -552,4 +732,9 @@ return '' + count + ' ' + word; | ||
function noExpectations(result) { | ||
return (result.failedExpectations.length + result.passedExpectations.length) === 0 && | ||
result.status === 'passed'; | ||
var allExpectations = | ||
result.failedExpectations.length + result.passedExpectations.length; | ||
return ( | ||
allExpectations === 0 && | ||
(result.status === 'passed' || result.status === 'failed') | ||
); | ||
} | ||
@@ -577,3 +762,6 @@ | ||
function HtmlSpecFilter(options) { | ||
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); | ||
var filterString = | ||
options && | ||
options.filterString() && | ||
options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); | ||
var filterPattern = new RegExp(filterString); | ||
@@ -615,5 +803,7 @@ | ||
function QueryString(options) { | ||
this.navigateWithNewParam = function (key, value) { | ||
options.getWindowLocation().search = this.fullStringWithNewParam(key, value); | ||
options.getWindowLocation().search = this.fullStringWithNewParam( | ||
key, | ||
value | ||
); | ||
}; | ||
@@ -636,3 +826,5 @@ | ||
for (var prop in paramMap) { | ||
qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop])); | ||
qStrPairs.push( | ||
encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]) | ||
); | ||
} | ||
@@ -661,3 +853,2 @@ return '?' + qStrPairs.join('&'); | ||
} | ||
} | ||
@@ -664,0 +855,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132876
915