@estruyf/github-actions-reporter
Advanced tools
Comparing version
@@ -5,2 +5,6 @@ # Changelog | ||
## [1.9.0] | ||
- [#17](https://github.com/estruyf/playwright-github-actions-reporter/issues/17): Added the ability to define which types of test results should be shown in the summary | ||
## [1.8.0] | ||
@@ -7,0 +11,0 @@ |
@@ -52,2 +52,5 @@ "use strict"; | ||
} | ||
if (typeof options.report === "undefined") { | ||
this.options.report = ["fail", "flaky", "pass", "skipped"]; | ||
} | ||
if (process.env.NODE_ENV === "development") { | ||
@@ -54,0 +57,0 @@ console.log(`Using development mode`); |
@@ -18,2 +18,3 @@ "use strict"; | ||
const getTestStatus_1 = require("./getTestStatus"); | ||
const getTestStatusIcon_1 = require("./getTestStatusIcon"); | ||
const getTestTitle_1 = require("./getTestTitle"); | ||
@@ -23,3 +24,3 @@ const getTestTags_1 = require("./getTestTags"); | ||
const getTestDuration_1 = require("./getTestDuration"); | ||
const getHtmlTable = (tests, showAnnotations, showTags, showError) => __awaiter(void 0, void 0, void 0, function* () { | ||
const getHtmlTable = (tests, showAnnotations, showTags, showError, displayLevel) => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a; | ||
@@ -45,5 +46,10 @@ const convert = new ansi_to_html_1.default(); | ||
content.push(`<tbody>`); | ||
const testRows = []; | ||
for (const test of tests) { | ||
// Get the last result | ||
const result = test.results[test.results.length - 1]; | ||
const testStatus = (0, getTestStatus_1.getTestStatus)(test, result); | ||
if (!displayLevel.includes(testStatus.toLowerCase())) { | ||
continue; | ||
} | ||
if (showAnnotations && test.annotations) { | ||
@@ -59,21 +65,25 @@ let colLength = 4; | ||
if (annotations) { | ||
content.push(`<tr>`); | ||
content.push(`<td colspan="${colLength}">${annotations}</td>`); | ||
content.push(`</tr>`); | ||
testRows.push(`<tr>`); | ||
testRows.push(`<td colspan="${colLength}">${annotations}</td>`); | ||
testRows.push(`</tr>`); | ||
} | ||
} | ||
content.push(`<tr>`); | ||
content.push(`<td>${(0, getTestTitle_1.getTestTitle)(test)}</td>`); | ||
content.push(`<td>${(0, getTestStatus_1.getTestStatus)(test, result)}</td>`); | ||
content.push(`<td>${(0, getTestDuration_1.getTestDuration)(result)}</td>`); | ||
content.push(`<td>${(result === null || result === void 0 ? void 0 : result.retry) || ""}</td>`); | ||
testRows.push(`<tr>`); | ||
testRows.push(`<td>${(0, getTestTitle_1.getTestTitle)(test)}</td>`); | ||
testRows.push(`<td>${(0, getTestStatusIcon_1.getTestStatusIcon)(test, result)} ${(0, getTestStatus_1.getTestStatus)(test, result)}</td>`); | ||
testRows.push(`<td>${(0, getTestDuration_1.getTestDuration)(result)}</td>`); | ||
testRows.push(`<td>${(result === null || result === void 0 ? void 0 : result.retry) || ""}</td>`); | ||
if (showTags) { | ||
content.push(`<td>${(0, getTestTags_1.getTestTags)(test)}</td>`); | ||
testRows.push(`<td>${(0, getTestTags_1.getTestTags)(test)}</td>`); | ||
} | ||
if (showError) { | ||
const error = ((_a = result === null || result === void 0 ? void 0 : result.error) === null || _a === void 0 ? void 0 : _a.message) || ""; | ||
content.push(`<td>${convert.toHtml(error)}</td>`); | ||
testRows.push(`<td>${convert.toHtml(error)}</td>`); | ||
} | ||
content.push(`</tr>`); | ||
testRows.push(`</tr>`); | ||
} | ||
if (testRows.length === 0) { | ||
return; | ||
} | ||
content.push(testRows.join("\n")); | ||
content.push(`</tbody>`); | ||
@@ -80,0 +90,0 @@ content.push(`</table>`); |
@@ -22,3 +22,4 @@ "use strict"; | ||
const getTestDuration_1 = require("./getTestDuration"); | ||
const getTableRows = (tests, showAnnotations, showTags, showError) => __awaiter(void 0, void 0, void 0, function* () { | ||
const getTestStatusIcon_1 = require("./getTestStatusIcon"); | ||
const getTableRows = (tests, showAnnotations, showTags, showError, displayLevel) => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a; | ||
@@ -56,6 +57,11 @@ const convert = new ansi_to_html_1.default(); | ||
} | ||
const tableRows = [tableHeaders]; | ||
const tableRows = []; | ||
for (const test of tests) { | ||
// Get the last result | ||
const result = test.results[test.results.length - 1]; | ||
// Check if the test should be shown | ||
const testStatus = (0, getTestStatus_1.getTestStatus)(test, result); | ||
if (!displayLevel.includes(testStatus.toLowerCase())) { | ||
continue; | ||
} | ||
if (showAnnotations && test.annotations) { | ||
@@ -86,3 +92,3 @@ let colLength = 4; | ||
{ | ||
data: (0, getTestStatus_1.getTestStatus)(test, result), | ||
data: `${(0, getTestStatusIcon_1.getTestStatusIcon)(test, result)} ${testStatus}`, | ||
header: false, | ||
@@ -114,4 +120,7 @@ }, | ||
} | ||
return tableRows; | ||
if (tableRows.length === 0) { | ||
return []; | ||
} | ||
return [tableHeaders, ...tableRows]; | ||
}); | ||
exports.getTableRows = getTableRows; |
@@ -9,12 +9,12 @@ "use strict"; | ||
if (status === "passed" && result.retry > 0) { | ||
value = `⚠️ Flaky`; | ||
value = `Flaky`; | ||
} | ||
else if (status === "passed") { | ||
value = "✅ Pass"; | ||
value = "Pass"; | ||
} | ||
else if (status === "skipped") { | ||
value = `⏭️ Skipped`; | ||
value = `Skipped`; | ||
} | ||
else { | ||
value = "❌ Fail"; | ||
value = "Fail"; | ||
} | ||
@@ -21,0 +21,0 @@ return value; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTestStatusIcon = void 0; | ||
const getTestOutcome_1 = require("./getTestOutcome"); | ||
const getTestStatusIcon = (tests) => { | ||
if (!tests || tests.length === 0) { | ||
return "❌"; | ||
const getTestStatus_1 = require("./getTestStatus"); | ||
const getTestStatusIcon = (test, result) => { | ||
let value = (0, getTestStatus_1.getTestStatus)(test, result); | ||
if (value === "Flaky") { | ||
value = `⚠️`; | ||
} | ||
const testOutcomes = tests.map((test) => { | ||
const lastResult = test.results[test.results.length - 1]; | ||
const outcome = test.outcome(); | ||
if (outcome === "flaky") { | ||
return "flaky"; | ||
} | ||
return (0, getTestOutcome_1.getTestOutcome)(test, lastResult); | ||
}); | ||
if (testOutcomes.includes("failed") || | ||
testOutcomes.includes("interrupted") || | ||
testOutcomes.includes("timedOut")) { | ||
return "❌"; | ||
else if (value === "Pass") { | ||
value = "✅"; | ||
} | ||
else if (testOutcomes.includes("flaky")) { | ||
return "⚠️"; | ||
else if (value === "Skipped") { | ||
value = `⏭️`; | ||
} | ||
return "✅"; | ||
else if (value === "Fail") { | ||
value = "❌"; | ||
} | ||
return value; | ||
}; | ||
exports.getTestStatusIcon = getTestStatusIcon; |
@@ -41,3 +41,3 @@ "use strict"; | ||
const getHtmlTable_1 = require("./getHtmlTable"); | ||
const getTestStatusIcon_1 = require("./getTestStatusIcon"); | ||
const getSuiteStatusIcon_1 = require("./getSuiteStatusIcon"); | ||
const getTableRows_1 = require("./getTableRows"); | ||
@@ -76,11 +76,16 @@ const getSummaryTitle_1 = require("./getSummaryTitle"); | ||
if (options.useDetails) { | ||
const content = yield (0, getHtmlTable_1.getHtmlTable)(tests[filePath], options.showAnnotations, options.showTags, !!options.showError); | ||
const content = yield (0, getHtmlTable_1.getHtmlTable)(tests[filePath], options.showAnnotations, options.showTags, !!options.showError, options.report); | ||
if (!content) { | ||
continue; | ||
} | ||
// Check if there are any failed tests | ||
const testStatusIcon = (0, getTestStatusIcon_1.getTestStatusIcon)(tests[filePath]); | ||
const testStatusIcon = (0, getSuiteStatusIcon_1.getSuiteStatusIcon)(tests[filePath]); | ||
summary.addDetails(`${testStatusIcon} ${(0, getTestHeading_1.getTestHeading)(fileName, os, project)}`, content); | ||
} | ||
else { | ||
summary.addHeading((0, getTestHeading_1.getTestHeading)(fileName, os, project), 2); | ||
const tableRows = yield (0, getTableRows_1.getTableRows)(tests[filePath], options.showAnnotations, options.showTags, !!options.showError); | ||
summary.addTable(tableRows); | ||
const tableRows = yield (0, getTableRows_1.getTableRows)(tests[filePath], options.showAnnotations, options.showTags, !!options.showError, options.report); | ||
if (tableRows.length !== 0) { | ||
summary.addHeading((0, getTestHeading_1.getTestHeading)(fileName, os, project), 2); | ||
summary.addTable(tableRows); | ||
} | ||
} | ||
@@ -87,0 +92,0 @@ } |
{ | ||
"name": "@estruyf/github-actions-reporter", | ||
"version": "1.8.0", | ||
"version": "1.9.0-beta.1026629", | ||
"description": "GitHub Actions reporter for Playwright", | ||
@@ -10,3 +10,2 @@ "main": "dist/index.js", | ||
"test": "NODE_ENV=development npx playwright test", | ||
"test:local": "act -j testing -P ubuntu-latest=catthehacker/ubuntu:act-latest --container-architecture linux/amd64 --env GITHUB_STEP_SUMMARY='/dev/stdout'", | ||
"test:jest": "jest --coverage --coverageDirectory=../coverage" | ||
@@ -51,2 +50,2 @@ }, | ||
} | ||
} | ||
} |
@@ -41,2 +41,3 @@ # GitHub Actions Reporter for Playwright | ||
| showError | Show error message in summary | `false` | | ||
| report | Define which types of test results should be shown in the summary | `['pass', 'skipped', 'fail', 'flaky']` | | ||
| quiet | Do not show any output in the console | `false` | | ||
@@ -48,6 +49,7 @@ | ||
import { defineConfig } from '@playwright/test'; | ||
import type { GitHubActionOptions } from '@estruyf/github-actions-reporter'; | ||
export default defineConfig({ | ||
reporter: [ | ||
['@estruyf/github-actions-reporter', { | ||
['@estruyf/github-actions-reporter', <GitHubActionOptions>{ | ||
title: 'My custom title', | ||
@@ -54,0 +56,0 @@ useDetails: true, |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
32128
10.35%24
20%662
11.82%70
2.94%1
Infinity%