File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 22
33All notable changes to this project will be documented in this file.
44
5+ ## [ 1.4.0]
6+
7+ - Add total passed, failed, and skipped to the summary
8+
59## [ 1.3.0]
610
711- Added warning test icon
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { getTestStatusIcon } from "./utils/getTestStatusIcon";
1414import { SUMMARY_ENV_VAR } from "@actions/core/lib/summary" ;
1515import { join } from "path" ;
1616import { existsSync , unlinkSync , writeFileSync } from "fs" ;
17+ import { getTotalStatus } from "./utils/getTotalStatus" ;
1718
1819interface GitHubActionOptions {
1920 title ?: string ;
@@ -56,7 +57,23 @@ class GitHubAction implements Reporter {
5657 const summary = core . summary ;
5758 summary . addHeading ( this . options . title || `Test results` , 1 ) ;
5859
59- summary . addRaw ( `Total tests: ${ this . suite . allTests ( ) . length } ` ) ;
60+ const totalStatus = getTotalStatus ( this . suite ?. suites ) ;
61+
62+ const headerText = [ `Total tests: ${ this . suite . allTests ( ) . length } ` ] ;
63+
64+ if ( totalStatus . passed > 0 ) {
65+ headerText . push ( `Passed: ${ totalStatus . passed } ` ) ;
66+ }
67+
68+ if ( totalStatus . failed > 0 ) {
69+ headerText . push ( `Failed: ${ totalStatus . failed } ` ) ;
70+ }
71+
72+ if ( totalStatus . skipped > 0 ) {
73+ headerText . push ( `Skipped: ${ totalStatus . skipped } ` ) ;
74+ }
75+
76+ summary . addRaw ( headerText . join ( ` - ` ) ) ;
6077
6178 if ( this . options . useDetails ) {
6279 summary . addSeparator ( ) ;
Original file line number Diff line number Diff line change 1+ import { Suite } from "@playwright/test/reporter" ;
2+
3+ export const getTotalStatus = (
4+ suites : Suite [ ]
5+ ) : {
6+ passed : number ;
7+ failed : number ;
8+ skipped : number ;
9+ } => {
10+ let total = {
11+ passed : 0 ,
12+ failed : 0 ,
13+ skipped : 0 ,
14+ } ;
15+
16+ for ( const suite of suites ) {
17+ const testOutcome = suite . allTests ( ) . map ( ( test ) => {
18+ const lastResult = test . results [ test . results . length - 1 ] ;
19+ return lastResult . status ;
20+ } ) ;
21+
22+ for ( const outcome of testOutcome ) {
23+ if ( outcome === "passed" ) {
24+ total . passed ++ ;
25+ } else if ( outcome === "failed" ) {
26+ total . failed ++ ;
27+ } else if ( outcome === "skipped" ) {
28+ total . skipped ++ ;
29+ }
30+ }
31+ }
32+
33+ return total ;
34+ } ;
You can’t perform that action at this time.
0 commit comments