wdio-timeline-reporter
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -5,4 +5,8 @@ const events = require('events'); | ||
const path = require('path'); | ||
const humanizeDuration = require('humanize-duration'); | ||
const round = { round: true }; | ||
const html = ` | ||
@@ -50,2 +54,3 @@ <!DOCTYPE html> | ||
</style> | ||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous"> | ||
</head> | ||
@@ -208,10 +213,6 @@ | ||
</div> | ||
<h3 class="title is-4">Total Duration: {{duration}}</h3> | ||
</div> | ||
</section> | ||
` | ||
const errorHtml = ` | ||
<div class="notification is-danger"> | ||
{{error}} | ||
</div> | ||
`; | ||
@@ -270,3 +271,3 @@ class TimelineReporter extends events.EventEmitter { | ||
let screenshotsCode = ''; | ||
let screenshotsHtml = ''; | ||
const runners = Object.keys(this.baseReporter.stats.runners); | ||
@@ -283,6 +284,7 @@ let total = 0, passed = 0, failed = 0, skipped = 0; | ||
for (let specId of Object.keys(runnerInfo.specs)) { | ||
let specHtml = ''; | ||
let specInfo = runnerInfo.specs[specId]; | ||
screenshotsCode += `<div class="box"><h4 class="title is-4">Spec: ${specInfo.files[0]}</h4>`; | ||
// suites | ||
for (let suiteName of Object.keys(specInfo.suites)) { | ||
let suiteHtml = ''; | ||
const suiteInfo = specInfo.suites[suiteName]; | ||
@@ -292,14 +294,6 @@ if (!suiteInfo.uid.includes('before all') | ||
&& Object.keys(suiteInfo.tests).length > 0) { | ||
screenshotsCode += `<div class="box"><h4 class="subtitle is-4">${suiteInfo.title}</h4>`; | ||
for (let testId of Object.keys(suiteInfo.tests)) { | ||
const { state, title, screenshots, error } = suiteInfo.tests[testId]; | ||
const isPending = state === 'pending'; | ||
const div1Opening = `<div class="test ${state}">`; | ||
const divClosing = '</div>'; | ||
const testNameTag = `<p class="subtitle is-5">${title}</p>` | ||
const pendingPostFix = isPending ? '-pending' : ''; | ||
const div2Opening = `<div class="screenshots${pendingPostFix}">`; | ||
const skippedHtml = isPending ? '<div class="notification is-warning">Skipped</div>' : ''; | ||
const div3Opening = `<div class="screenshots-scroll-container${pendingPostFix}">${skippedHtml}`; | ||
const { state, title, screenshots, error, _duration, start, end } = suiteInfo.tests[testId]; | ||
const imagesHtml = screenshots.reduce((accumulator, currentValue) => { | ||
@@ -322,25 +316,51 @@ // error screenshots dont come with path | ||
let errorHtmlCreated = ''; | ||
let errorHtml = ''; | ||
if (state === 'fail' && error) { | ||
errorHtmlCreated += '<table class="table is-striped">'; | ||
const { message, type, stack } = error; | ||
if (type) { | ||
errorHtmlCreated += `<tr><td>Type:</td><td>${type}</td></tr>`; | ||
} | ||
if (message) { | ||
errorHtmlCreated += `<tr><td>Message:</td><td>${message}</td></tr>`; | ||
} | ||
if (stack) { | ||
errorHtmlCreated += `<tr><td>Stack:</td><td>${stack}</td></tr>`; | ||
} | ||
errorHtmlCreated += '</table>'; | ||
errorHtml = ` | ||
<table class="table is-striped" border="10" bordercolor="#FF3860"> | ||
${!!type ? `<tr><td>Type:</td><td>${type}</td></tr>` : ``} | ||
${!!message ? `<tr><td>Message:</td><td>${message.replace(/<|>/g, '')}</td></tr>` : ``} | ||
${!!stack ? `<tr><td>Stack:</td><td>${stack.replace(/<|>/g, '')}</td></tr>` : ``} | ||
</table> | ||
`; | ||
} | ||
!!errorHtmlCreated && (errorHtmlCreated = errorHtml.replace('{{error}}', errorHtmlCreated)); | ||
const isPending = state === 'pending' | ||
const pendingPostFix = isPending ? '-pending' : ''; | ||
screenshotsCode += div1Opening + testNameTag + div2Opening + div3Opening + imagesHtml + divClosing.repeat(2) + errorHtmlCreated + divClosing; | ||
suiteHtml += ` | ||
<div class="test ${state}"> | ||
<p class="subtitle is-5">Test Name: ${title}</p> | ||
<div class="columns"> | ||
<div class="column is-half"> | ||
<table class="table is-striped is-fullwidth is-bordered"> | ||
<tr><td>Duration:</td><td>${humanizeDuration(_duration, round)}</td></tr> | ||
<tr><td>Start:</td><td>${start}</td></tr> | ||
<tr><td>End:</td><td>${end}</td></tr> | ||
</table> | ||
</div> | ||
</div> | ||
<div class="screenshots${pendingPostFix}"> | ||
<div class="screenshots-scroll-container${pendingPostFix}"> | ||
${isPending ? `<div class="notification is-warning">Skipped</div>` : ``} | ||
${imagesHtml} | ||
${errorHtml} | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
} | ||
screenshotsCode += '</div>'; | ||
specHtml += ` | ||
<div class="box"><h4 class="subtitle is-4">${suiteInfo.title}</h4> | ||
${suiteHtml} | ||
</div> | ||
`; | ||
} | ||
} | ||
screenshotsCode += '</div>'; | ||
screenshotsHtml += | ||
`<div class="box"><h4 class="title is-4">Spec: ${specInfo.files[0]} (${humanizeDuration(specInfo._duration, round)})</h4> | ||
${specHtml} | ||
</div> | ||
` | ||
} | ||
@@ -352,5 +372,6 @@ } | ||
.replace('{{failed}}', failed) | ||
.replace('{{skipped}}', skipped); | ||
.replace('{{skipped}}', skipped) | ||
.replace('{{duration}}', humanizeDuration(this.baseReporter.stats._duration, round)); | ||
const finalHtml = html.replace('{{result-summary}}', resultSummaryHtml).replace('{{content}}', screenshotsCode); | ||
const finalHtml = html.replace('{{result-summary}}', resultSummaryHtml).replace('{{content}}', screenshotsHtml); | ||
@@ -357,0 +378,0 @@ const fileName = 'timeline-report.html'; |
{ | ||
"name": "wdio-timeline-reporter", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/timeline-reporter.js", |
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
16900
341