File tree Expand file tree Collapse file tree
packages/functional-tests/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,29 @@ import {
1313 TestResult ,
1414} from '@playwright/test/reporter' ;
1515
16+ /**
17+ * Converts milliseconds to human-readable format
18+ * If the time is less than 1 second, it shows milliseconds
19+ * If the time is less than 1 minute, it shows seconds
20+ * And if over 1 minute, it shows minutes and seconds
21+ * @param ms
22+ */
23+ const formatTime = ( ms : number ) => {
24+ // protect against bad input so we don't crash the reporter
25+ if ( ms === undefined || ms === null || isNaN ( ms ) || ms < 0 ) {
26+ return 'unknown' ;
27+ }
28+ if ( ms < 1000 ) {
29+ return `${ ms } ms` ;
30+ }
31+ const seconds = Math . floor ( ms / 1000 ) ;
32+ if ( seconds < 60 ) {
33+ return `${ seconds } s` ;
34+ }
35+ const minutes = Math . floor ( seconds / 60 ) ;
36+ return `${ minutes } m${ seconds % 60 } s` ;
37+ } ;
38+
1639class CIReporter implements Reporter {
1740 private fixmeCount = 0 ;
1841 private passCount = 0 ;
@@ -48,7 +71,7 @@ class CIReporter implements Reporter {
4871 console . log (
4972 `${ status } ${ path . relative ( process . cwd ( ) , test . location . file ) } : ${
5073 test . title
51- } `
74+ } ( ${ formatTime ( result . duration ) } ) `
5275 ) ;
5376 if ( test . outcome ( ) === 'unexpected' ) {
5477 console . log ( result . error ?. stack ) ;
You can’t perform that action at this time.
0 commit comments