From 8587600ce58e27c35d6d9adb1d5dffa236081df7 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 17 Jul 2024 15:08:36 +0200 Subject: [PATCH] [Suggestion] Add colorblind support #5 --- CHANGELOG.md | 1 + README.md | 1 + playwright.config.ts | 1 + src/index.ts | 2 ++ src/processResults.ts | 24 ++++++++++++++++++++---- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f59d41..a0c9fd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ## [0.0.8] - [#4](https://github.com/playwright-community/playwright-msteams-reporter/issues/4): Added support for flaky tests +- [#5](https://github.com/playwright-community/playwright-msteams-reporter/issues/5): Added the `enableEmoji` setting to show an emoji based on the test status ## [0.0.7] diff --git a/README.md b/README.md index b7f6abd..54158e7 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ The reporter supports the following configuration options: | `notifyOnSuccess` | Notify on success | `boolean` | `false` | `true` | | `mentionOnFailure` | Mention users on failure (comma separated list) | `string` | `false` | `undefined` | | `mentionOnFailureText` | Text to mention users on failure | `string` | `false` | `{mentions} please validate the test results.` | +| `enableEmoji` | Show an emoji based on the test status | `boolean` | `false` | `false` | | `quiet` | Do not show any output in the console | `boolean` | `false` | `false` | | `debug` | Show debug information | `boolean` | `false` | `false` | diff --git a/playwright.config.ts b/playwright.config.ts index 2890fc6..89f6644 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -28,6 +28,7 @@ const config: PlaywrightTestConfig<{}, {}> = { linkTextOnFailure: "Report an issue", mentionOnFailure: "elio@struyfconsulting.be", mentionOnFailureText: "", + enableEmoji: false, debug: true, }, ], diff --git a/src/index.ts b/src/index.ts index 289f6a7..13243f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,6 +20,7 @@ export interface MsTeamsReporterOptions { notifyOnSuccess?: boolean; mentionOnFailure?: string; mentionOnFailureText?: string; + enableEmoji?: boolean; quiet?: boolean; debug?: boolean; } @@ -37,6 +38,7 @@ export default class MsTeamsReporter implements Reporter { notifyOnSuccess: true, mentionOnFailure: undefined, mentionOnFailureText: "{mentions} please validate the test results.", + enableEmoji: false, quiet: false, debug: false, }; diff --git a/src/processResults.ts b/src/processResults.ts index 53938b6..2e009d5 100644 --- a/src/processResults.ts +++ b/src/processResults.ts @@ -48,18 +48,34 @@ export const processResults = async ( table.rows.push(createTableRow("Type", "Total")); table.rows.push( - createTableRow("Passed", totalStatus.passed, { style: "good" }) + createTableRow( + `${options.enableEmoji ? "✅ " : ""}Passed`, + totalStatus.passed, + { style: "good" } + ) ); if (totalStatus.flaky) { table.rows.push( - createTableRow("Flaky", totalStatus.flaky, { style: "warning" }) + createTableRow( + `${options.enableEmoji ? "⚠️ " : ""}Flaky`, + totalStatus.flaky, + { style: "warning" } + ) ); } table.rows.push( - createTableRow("Failed", totalStatus.failed, { style: "attention" }) + createTableRow( + `${options.enableEmoji ? "❌ " : ""}Failed`, + totalStatus.failed, + { style: "attention" } + ) ); table.rows.push( - createTableRow("Skipped", totalStatus.skipped, { style: "accent" }) + createTableRow( + `${options.enableEmoji ? "⏭️ " : ""}Skipped`, + totalStatus.skipped, + { style: "accent" } + ) ); table.rows.push( createTableRow("Total tests", totalTests, {