Skip to content

Commit

Permalink
Merge pull request #16 from estruyf/dev
Browse files Browse the repository at this point in the history
Update local summary location
  • Loading branch information
estruyf authored Jul 18, 2024
2 parents ca7d5d0 + 96bab1a commit 89ac223
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

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

## [1.8.0]

- Added `⏭️` icon for skipped tests
- Added flaky test support

## [1.7.0]

- [#14](https://github.com/estruyf/playwright-github-actions-reporter/issues/14): Added the `quiet` option to disable console logging + `stdErr` output support
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@estruyf/github-actions-reporter",
"version": "1.7.0",
"version": "1.8.0",
"description": "GitHub Actions reporter for Playwright",
"main": "dist/index.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/getTestStatus.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getTestStatus } from "./getTestStatus";

describe("getTestStatus", () => {
it("should return '⚠️ Pass' when test status is 'passed' and result retry is greater than 0", () => {
it("should return '⚠️ Flaky' when test status is 'passed' and result retry is greater than 0", () => {
const test: any = {
outcome: () => "expected",
};
Expand All @@ -12,7 +12,7 @@ describe("getTestStatus", () => {

const status = getTestStatus(test, result);

expect(status).toBe("⚠️ Pass");
expect(status).toBe("⚠️ Flaky");
});

it("should return '✅ Pass' when test status is 'passed' and result retry is 0", () => {
Expand All @@ -29,7 +29,7 @@ describe("getTestStatus", () => {
expect(status).toBe("✅ Pass");
});

it("should return '️ Skipped' when test status is 'skipped'", () => {
it("should return '️ Skipped' when test status is 'skipped'", () => {
const test: any = {
outcome: () => "expected",
};
Expand All @@ -40,7 +40,7 @@ describe("getTestStatus", () => {

const status = getTestStatus(test, result);

expect(status).toBe("️ Skipped");
expect(status).toBe("️ Skipped");
});

it("should return '❌ Fail' when test status is not 'passed' or 'skipped'", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/getTestStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export const getTestStatus = (test: TestCase, result: TestResult) => {
let status = getTestOutcome(test, result);

if (status === "passed" && result.retry > 0) {
value = `⚠️ Pass`;
value = `⚠️ Flaky`;
} else if (status === "passed") {
value = "✅ Pass";
} else if (status === "skipped") {
value = `️ Skipped`;
value = `️ Skipped`;
} else {
value = "❌ Fail";
}
Expand Down
24 changes: 19 additions & 5 deletions src/utils/getTestStatusIcon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,29 @@ import { getTestStatusIcon } from "./getTestStatusIcon";

describe("getTestStatusIcon", () => {
it("should return ✅ if all tests have passed", () => {
const tests = [{ results: [{ status: "passed" }] }] as TestCase[];
const tests = [
{ results: [{ status: "passed" }], outcome: () => "expected" },
] as TestCase[];

const result = getTestStatusIcon(tests);

expect(result).toBe("✅");
});

it("should return ⚠️ if any test has been skipped", () => {
const tests = [{ results: [{ status: "skipped" }] }] as TestCase[];
it("should return ⏭️ if any test has been skipped", () => {
const tests = [
{ results: [{ status: "skipped" }], outcome: () => "expected" },
] as TestCase[];

const result = getTestStatusIcon(tests);

expect(result).toBe("⚠️");
expect(result).toBe("");
});

it("should return ❌ if any test has failed, interrupted, or timed out", () => {
const tests = [{ results: [{ status: "failed" }] }] as TestCase[];
const tests = [
{ results: [{ status: "failed" }], outcome: () => "expected" },
] as TestCase[];

const result = getTestStatusIcon(tests);

Expand All @@ -41,4 +47,12 @@ describe("getTestStatusIcon", () => {

expect(result).toBe("❌");
});

it("should return ⚠️ if any test is flaky", () => {
const tests = [{ results: [{}], outcome: () => "flaky" }] as TestCase[];

const result = getTestStatusIcon(tests);

expect(result).toBe("⚠️");
});
});
7 changes: 6 additions & 1 deletion src/utils/getTestStatusIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export const getTestStatusIcon = (tests: TestCase[]) => {

const testOutcomes = tests.map((test) => {
const lastResult = test.results[test.results.length - 1];
const outcome = test.outcome();
if (outcome === "flaky") {
return "flaky";
}

return getTestOutcome(test, lastResult);
});

Expand All @@ -17,7 +22,7 @@ export const getTestStatusIcon = (tests: TestCase[]) => {
testOutcomes.includes("timedOut")
) {
return "❌";
} else if (testOutcomes.includes("skipped")) {
} else if (testOutcomes.includes("flaky")) {
return "⚠️";
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/processResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const processResults = async (
options: GitHubActionOptions
) => {
if (process.env.NODE_ENV === "development") {
const summaryFile = join(__dirname, "../summary.html");
const summaryFile = join(__dirname, "../../summary.html");
if (existsSync(summaryFile)) {
unlinkSync(summaryFile);
}
Expand Down

0 comments on commit 89ac223

Please sign in to comment.