@testomatio/reporter
Advanced tools
Comparing version 1.4.11-beta-bitbucket-pipe to 1.4.12-beta-bitbucket-pipe
@@ -27,3 +27,3 @@ const debug = require('debug')('@testomatio/reporter:pipe:bitbucket'); | ||
this.token = params.BITBUCKET_PAT || process.env.BITBUCKET_PAT || this.ENV.BITBUCKET_PAT; | ||
this.hiddenCommentData = `<!--- testomat.io report ${process.env.BITBUCKET_STEP_NAME || ''} -->`; | ||
this.hiddenCommentData = `Testomat.io report: ${process.env.BITBUCKET_BRANCH || ''}`; | ||
@@ -51,2 +51,7 @@ debug( | ||
async cleanLog(log) { | ||
const stripAnsi = (await import('strip-ansi')).default; | ||
return stripAnsi(log); | ||
} | ||
// Prepare the run (if needed) | ||
@@ -76,2 +81,8 @@ async prepareRun() {} | ||
// Clean up the logs from ANSI codes | ||
for (let i = 0; i < this.tests.length; i++) { | ||
this.tests[i].message = await this.cleanLog(this.tests[i].message || ''); | ||
this.tests[i].stack = await this.cleanLog(this.tests[i].stack || ''); | ||
} | ||
// Create a comment on Bitbucket | ||
@@ -85,11 +96,11 @@ const passedCount = this.tests.filter(t => t.status === 'passed').length; | ||
| [![Testomat.io Report](${testomatLogoURL})](https://testomat.io) | ${statusEmoji( | ||
| ![Testomat.io Report](${testomatLogoURL}) | ${statusEmoji( | ||
runParams.status, | ||
)} ${runParams.status.toUpperCase()} ${statusEmoji(runParams.status)} | | ||
| --- | --- | | ||
| Tests | ✔️ **${this.tests.length}** tests run | | ||
| Summary | ${statusEmoji('failed')} **${failedCount}** failed; ${statusEmoji( | ||
| **Tests** | ✔️ **${this.tests.length}** tests run | | ||
| **Summary** | ${statusEmoji('failed')} **${failedCount}** failed; ${statusEmoji( | ||
'passed', | ||
)} **${passedCount}** passed; **${statusEmoji('skipped')}** ${skippedCount} skipped | | ||
| Duration | 🕐 **${humanizeDuration( | ||
| **Duration** | 🕐 **${humanizeDuration( | ||
parseInt( | ||
@@ -105,5 +116,5 @@ this.tests.reduce((a, t) => a + (t.run_time || 0), 0), | ||
if (this.ENV.BITBUCKET_STEP_NAME && this.ENV.BITBUCKET_STEP_UUID) { | ||
if (this.ENV.BITBUCKET_BRANCH && this.ENV.BITBUCKET_COMMIT) { | ||
// eslint-disable-next-line max-len | ||
summary += `| Job | 👷 [${this.ENV.BITBUCKET_STEP_UUID}](${this.ENV.BITBUCKET_PIPELINE_STEP_URL})<br>Name: **${this.ENV.BITBUCKET_STEP_NAME}** | `; | ||
summary += `| **Job** | 👷 [Run: ${this.ENV.BITBUCKET_COMMIT}](https://bitbucket.org/${this.ENV.BITBUCKET_REPO_FULL_NAME}/pipelines/results/${this.ENV.BITBUCKET_BUILD_NUMBER}") Branch: **${this.ENV.BITBUCKET_BRANCH}** |`; | ||
} | ||
@@ -115,5 +126,4 @@ | ||
.map(t => { | ||
let text = `#### ${statusEmoji('failed')} ${fullName(t)} `; | ||
text += '\n\n'; | ||
if (t.message) | ||
let text = `${statusEmoji('failed')} ${fullName(t)}\n`; | ||
if (t.message) { | ||
text += `> ${t.message | ||
@@ -123,20 +133,24 @@ .replace(/[^\x20-\x7E]/g, '') | ||
.trim()}\n`; | ||
if (t.stack) text += `\`\`\`diff\n${t.stack.replace(ansiRegExp(), '').trim()}\n\`\`\`\n`; | ||
} | ||
if (t.stack) { | ||
text += `\n\`\`\`diff\n${t.stack | ||
.replace(ansiRegExp(), '') | ||
.replace( | ||
/^[\s\S]*################\[ Failure \]################/g, | ||
'################[ Failure ]################', | ||
) | ||
.trim()}\n\`\`\`\n`; | ||
} | ||
if (t.artifacts && t.artifacts.length && !this.ENV.TESTOMATIO_PRIVATE_ARTIFACTS) { | ||
t.artifacts | ||
.filter(f => !!f) | ||
.filter(f => f.endsWith('.png')) | ||
.forEach(f => { | ||
if (f.endsWith('.png')) { | ||
text += `![](${f})\n`; | ||
return text; | ||
text += `![Image](${f})\n`; | ||
} else { | ||
text += `[📄 ${path.basename(f)}](${f})\n`; | ||
} | ||
text += `[📄 ${path.basename(f)}](${f})\n`; | ||
return text; | ||
}); | ||
} | ||
text += '\n---\n'; | ||
text += `\n---\n`; | ||
return text; | ||
@@ -148,17 +162,15 @@ }); | ||
if (failures.length) { | ||
body += `\n<details>\n<summary><h3>🟥 Failures (${failures.length})</h3></summary>\n\n${failures.join('\n')}\n`; | ||
if (failures.length > 20) { | ||
body += '\n> Notice\n> Only first 20 failures shown*'; | ||
body += `\n🟥 **Failures (${failures.length})**\n\n* ${failures.join('\n* ')}\n`; | ||
if (failures.length > 10) { | ||
body += `\n> Notice: Only the first 10 failures are shown.`; | ||
} | ||
body += '\n\n</details>'; | ||
} | ||
if (this.tests.length > 0) { | ||
body += '\n<details>\n<summary><h3>🐢 Slowest Tests</h3></summary>\n\n'; | ||
body += `\n\n**🐢 Slowest Tests**\n\n`; | ||
body += this.tests | ||
.sort((a, b) => b.run_time - a.run_time) | ||
.slice(0, 5) | ||
.map(t => `* ${fullName(t)} (${humanizeDuration(parseFloat(t.run_time))})`) | ||
.map(t => `* **${fullName(t)}** (${humanizeDuration(parseFloat(t.run_time))})`) | ||
.join('\n'); | ||
body += '\n</details>'; | ||
} | ||
@@ -175,2 +187,3 @@ | ||
debug(`Adding comment via URL: ${commentsRequestURL}`); | ||
debug(`Final Bitbucket API call body: ${body}`); | ||
@@ -191,3 +204,3 @@ try { | ||
// eslint-disable-next-line max-len | ||
const commentURL = `${this.ENV.BITBUCKET_REPO_URL}/pull-requests/${this.ENV.BITBUCKET_PR_ID}#comment-${commentID}`; | ||
const commentURL = `https://bitbucket.org/${this.ENV.BITBUCKET_WORKSPACE}/${this.ENV.BITBUCKET_REPO_SLUG}/pull-requests/${this.ENV.BITBUCKET_PR_ID}#comment-${commentID}`; | ||
@@ -248,3 +261,2 @@ console.log(APP_PREFIX, chalk.yellow('Bitbucket'), `Report created: ${chalk.magenta(commentURL)}`); | ||
} | ||
// Pass next env var if need to clear all previous reports; | ||
@@ -251,0 +263,0 @@ // only the last one is removed by default |
{ | ||
"name": "@testomatio/reporter", | ||
"version": "1.4.11-beta-bitbucket-pipe", | ||
"version": "1.4.12-beta-bitbucket-pipe", | ||
"description": "Testomatio Reporter Client", | ||
@@ -36,2 +36,3 @@ "main": "./lib/reporter.js", | ||
"promise-retry": "^2.0.1", | ||
"strip-ansi": "^7.1.0", | ||
"uuid": "^9.0.0" | ||
@@ -38,0 +39,0 @@ }, |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
288467
5399
27
+ Addedstrip-ansi@^7.1.0
+ Addedfast-xml-parser@4.5.0(transitive)
- Removedfast-xml-parser@4.5.1(transitive)