@estruyf/github-actions-reporter
Advanced tools
Comparing version
@@ -11,2 +11,3 @@ # Changelog | ||
- Added retries count | ||
- Added `showError` option | ||
@@ -13,0 +14,0 @@ ## [1.0.0] |
@@ -81,10 +81,10 @@ "use strict"; | ||
if (this.options.useDetails) { | ||
const content = (0, getHtmlTable_1.getHtmlTable)(tests[filePath]); | ||
const content = (0, getHtmlTable_1.getHtmlTable)(tests[filePath], !!this.options.showError); | ||
// Check if there are any failed tests | ||
const hasFailedTests = (0, checkForFailedTests_1.checkForFailedTests)(tests[filePath]); | ||
summary.addDetails(`${hasFailedTests ? "❌" : "✅"} ${fileName} (${os}/${project})`, content); | ||
summary.addDetails(`${hasFailedTests ? "❌" : "✅"} ${fileName} (${os}${project.name ? ` / ${project.name}` : ""})`, content); | ||
} | ||
else { | ||
summary.addHeading(`${fileName} (${os}/${project})`, 2); | ||
const tableRows = (0, getTableRows_1.getTableRows)(tests[filePath]); | ||
summary.addHeading(`${fileName} (${os}${project.name ? ` / ${project.name}` : ""})`, 2); | ||
const tableRows = (0, getTableRows_1.getTableRows)(tests[filePath], !!this.options.showError); | ||
summary.addTable(tableRows); | ||
@@ -91,0 +91,0 @@ } |
@@ -8,4 +8,4 @@ "use strict"; | ||
}); | ||
return failedTests.length === 0; | ||
return failedTests.length > 0; | ||
}; | ||
exports.checkForFailedTests = checkForFailedTests; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getHtmlTable = void 0; | ||
const getHtmlTable = (tests) => { | ||
const ansi_to_html_1 = __importDefault(require("ansi-to-html")); | ||
const getHtmlTable = (tests, showError) => { | ||
const convert = new ansi_to_html_1.default(); | ||
const content = []; | ||
@@ -14,2 +19,5 @@ content.push(`<br>`); | ||
content.push(`<th>Retries</th>`); | ||
if (showError) { | ||
content.push(`<th>Error</th>`); | ||
} | ||
content.push(`</tr>`); | ||
@@ -26,2 +34,7 @@ content.push(`</thead>`); | ||
content.push(`<td>${result.retry}</td>`); | ||
if (showError) { | ||
content.push(`<td>${result.error && result.error.message | ||
? convert.toHtml(result.error.message) | ||
: ""}</td>`); | ||
} | ||
content.push(`</tr>`); | ||
@@ -28,0 +41,0 @@ } |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTableRows = void 0; | ||
const getTableRows = (tests) => { | ||
const tableRows = [ | ||
[ | ||
{ | ||
data: "Test", | ||
header: true, | ||
}, | ||
{ | ||
data: "Status", | ||
header: true, | ||
}, | ||
{ | ||
data: "Duration", | ||
header: true, | ||
}, | ||
{ | ||
data: "Retries", | ||
header: true, | ||
}, | ||
], | ||
const ansi_to_html_1 = __importDefault(require("ansi-to-html")); | ||
const getTableRows = (tests, showError) => { | ||
const convert = new ansi_to_html_1.default(); | ||
const tableHeaders = [ | ||
{ | ||
data: "Test", | ||
header: true, | ||
}, | ||
{ | ||
data: "Status", | ||
header: true, | ||
}, | ||
{ | ||
data: "Duration", | ||
header: true, | ||
}, | ||
{ | ||
data: "Retries", | ||
header: true, | ||
}, | ||
]; | ||
if (showError) { | ||
tableHeaders.push({ | ||
data: "Error", | ||
header: true, | ||
}); | ||
} | ||
const tableRows = [tableHeaders]; | ||
for (const test of tests) { | ||
// Get the last result | ||
const result = test.results[test.results.length - 1]; | ||
tableRows.push([ | ||
const tableRow = [ | ||
{ | ||
@@ -45,3 +55,12 @@ data: test.title, | ||
}, | ||
]); | ||
]; | ||
if (showError) { | ||
tableRow.push({ | ||
data: result.error && result.error.message | ||
? convert.toHtml(result.error.message) | ||
: "", | ||
header: false, | ||
}); | ||
} | ||
tableRows.push(tableRow); | ||
} | ||
@@ -48,0 +67,0 @@ return tableRows; |
{ | ||
"name": "@estruyf/github-actions-reporter", | ||
"version": "1.1.0-beta.5902635", | ||
"version": "1.1.0-beta.5903256", | ||
"description": "GitHub Actions reporter for Playwright", | ||
@@ -37,3 +37,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@actions/core": "^1.10.0" | ||
"@actions/core": "^1.10.0", | ||
"ansi-to-html": "^0.7.2" | ||
}, | ||
@@ -40,0 +41,0 @@ "peerDependencies": { |
@@ -38,2 +38,3 @@ # GitHub Actions Reporter for Playwright | ||
| useDetails | Use details in summary which creates expandable content | `false` | | ||
| showError | Show error message in summary | `false` | | ||
@@ -49,3 +50,4 @@ To use these option, you can update the reporter configuration: | ||
title: 'My custom title', | ||
useDetails: true | ||
useDetails: true, | ||
showError: true | ||
}] | ||
@@ -52,0 +54,0 @@ ], |
12655
12.45%223
16.75%63
3.28%3
50%+ Added
+ Added
+ Added