Skip to content

Commit ed0fcc0

Browse files
authored
Merge pull request #3 from estruyf/dev
2 parents 84383e3 + 24facc7 commit ed0fcc0

13 files changed

+104
-24
lines changed

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: npm ci
2424

2525
- name: Install Playwright Browsers
26-
run: npx playwright install --with-deps
26+
run: npx playwright install --with-deps chromium
2727

2828
- name: Run Playwright tests
2929
run: npx playwright test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
dist
33
node_modules
44
test-results
5+
summary.html

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.3.0]
6+
7+
- Added warning test icon
8+
- Added `skipped` status
9+
510
## [1.2.0]
611

712
- Show console logging

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "@estruyf/github-actions-reporter",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "GitHub Actions reporter for Playwright",
55
"main": "dist/index.js",
66
"scripts": {
77
"build": "tsc",
88
"watch": "tsc -w",
9-
"test": "npx playwright test"
9+
"test": "NODE_ENV=development npx playwright test",
10+
"test:local": "act -j testing -P ubuntu-latest=catthehacker/ubuntu:act-latest --container-architecture linux/amd64 --env GITHUB_STEP_SUMMARY='/dev/stdout'"
1011
},
1112
"author": "Elio Struyf <[email protected]>",
1213
"license": "MIT",

playwright.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const config: PlaywrightTestConfig<{}, {}> = {
88
},
99
fullyParallel: false,
1010
forbidOnly: !!process.env.CI,
11-
retries: process.env.CI ? 2 : 1,
12-
workers: process.env.CI ? 1 : undefined,
11+
retries: process.env.CI ? 2 : 2,
12+
workers: process.env.CI ? 1 : 1,
1313
reporter: [
1414
["./src/index.ts", { title: "Reporter testing", showError: true }],
1515
[

src/index.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import * as core from "@actions/core";
1010
import { basename } from "path";
1111
import { getHtmlTable } from "./utils/getHtmlTable";
1212
import { getTableRows } from "./utils/getTableRows";
13-
import { checkForFailedTests } from "./utils/checkForFailedTests";
14-
import Convert from "ansi-to-html";
13+
import { getTestStatusIcon } from "./utils/getTestStatusIcon";
14+
import { SUMMARY_ENV_VAR } from "@actions/core/lib/summary";
15+
import { join } from "path";
16+
import { existsSync, unlinkSync, writeFileSync } from "fs";
1517

1618
interface GitHubActionOptions {
1719
title?: string;
@@ -39,6 +41,16 @@ class GitHubAction implements Reporter {
3941
}
4042

4143
async onEnd(result: FullResult) {
44+
if (process.env.NODE_ENV === "development") {
45+
const summaryFile = join(__dirname, "../summary.html");
46+
if (existsSync(summaryFile)) {
47+
unlinkSync(summaryFile);
48+
}
49+
writeFileSync(summaryFile, "", "utf-8");
50+
process.env[SUMMARY_ENV_VAR] = summaryFile;
51+
process.env.GITHUB_ACTIONS = "true";
52+
}
53+
4254
if (process.env.GITHUB_ACTIONS && this.suite) {
4355
const os = process.platform;
4456
const summary = core.summary;
@@ -84,10 +96,10 @@ class GitHubAction implements Reporter {
8496
);
8597

8698
// Check if there are any failed tests
87-
const hasFailedTests = checkForFailedTests(tests[filePath]);
99+
const testStatusIcon = getTestStatusIcon(tests[filePath]);
88100

89101
summary.addDetails(
90-
`${hasFailedTests ? "❌" : "✅"} ${fileName} (${os}${
102+
`${testStatusIcon} ${fileName} (${os}${
91103
project!.name ? ` / ${project!.name}` : ""
92104
})`,
93105
content

src/utils/checkForFailedTests.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/utils/getHtmlTable.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { TestCase } from "@playwright/test/reporter";
22
import Convert from "ansi-to-html";
3+
import { getTestStatus } from "./getTestStatus";
34

45
export const getHtmlTable = (tests: TestCase[], showError: boolean): string => {
56
const convert = new Convert();
@@ -27,9 +28,7 @@ export const getHtmlTable = (tests: TestCase[], showError: boolean): string => {
2728

2829
content.push(`<tr>`);
2930
content.push(`<td>${test.title}</td>`);
30-
content.push(
31-
`<td>${result.status === "passed" ? "✅ Pass" : "❌ Fail"}</td>`
32-
);
31+
content.push(`<td>${getTestStatus(result)}</td>`);
3332
content.push(`<td>${result.duration / 1000}s</td>`);
3433
content.push(`<td>${result.retry}</td>`);
3534
if (showError) {

src/utils/getTableRows.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { SummaryTableRow } from "@actions/core/lib/summary";
22
import { TestCase } from "@playwright/test/reporter";
33
import Convert from "ansi-to-html";
4+
import { getTestStatus } from "./getTestStatus";
45

56
export const getTableRows = (
67
tests: TestCase[],
@@ -46,7 +47,7 @@ export const getTableRows = (
4647
header: false,
4748
},
4849
{
49-
data: result.status === "passed" ? "✅ Pass" : "❌ Fail",
50+
data: getTestStatus(result),
5051
header: false,
5152
},
5253
{

0 commit comments

Comments
 (0)