22 Envelope ,
33 Location ,
44 Pickle ,
5+ TestCaseFinished ,
6+ TestCaseStarted ,
57 TestRunFinished ,
68 TestRunStarted ,
79 TestStepResult ,
@@ -67,10 +69,20 @@ export class SummaryPrinter {
6769
6870 const picklesByStatus = new Map <
6971 TestStepResultStatus ,
70- Array < { pickle : Pickle ; location : Location | undefined ; testStepResult : TestStepResult } >
72+ Array < {
73+ pickle : Pickle
74+ location : Location | undefined
75+ testCaseStarted : TestCaseStarted
76+ testCaseFinished : TestCaseFinished
77+ testStepResult : TestStepResult
78+ } >
7179 > ( )
7280
7381 for ( const testCaseFinished of this . query . findAllTestCaseFinished ( ) ) {
82+ const testCaseStarted = ensure (
83+ this . query . findTestCaseStartedBy ( testCaseFinished ) ,
84+ 'TestCaseStarted must exist for TestCaseFinished'
85+ )
7486 const pickle = ensure (
7587 this . query . findPickleBy ( testCaseFinished ) ,
7688 'Pickle must exist for TestCaseFinished'
@@ -84,6 +96,8 @@ export class SummaryPrinter {
8496 picklesByStatus . get ( testStepResult . status ) ! . push ( {
8597 pickle,
8698 location,
99+ testCaseStarted,
100+ testCaseFinished,
87101 testStepResult,
88102 } )
89103 }
@@ -94,28 +108,35 @@ export class SummaryPrinter {
94108 if ( picklesForThisStatus . length > 0 ) {
95109 this . println ( )
96110 this . println ( formatNonPassingTitle ( status , this . options . theme , this . stream ) )
97- picklesForThisStatus . forEach ( ( { pickle, location, testStepResult } , index ) => {
98- const formattedLocation = formatPickleLocation (
99- pickle ,
100- location ,
101- this . options . theme ,
102- this . stream
103- )
104- this . println (
105- indent ( `${ index + 1 } ) ${ pickle . name } ${ formattedLocation } ` , GHERKIN_INDENT_LENGTH )
106- )
107- if ( status === TestStepResultStatus . FAILED ) {
108- const content = formatTestStepResultError (
109- testStepResult ,
111+ picklesForThisStatus . forEach (
112+ ( { pickle, location, testCaseStarted, testStepResult } , index ) => {
113+ const formattedLocation = formatPickleLocation (
114+ pickle ,
115+ location ,
110116 this . options . theme ,
111117 this . stream
112118 )
113- if ( content ) {
114- this . println ( indent ( content , GHERKIN_INDENT_LENGTH + ERROR_INDENT_LENGTH + 1 ) )
115- this . println ( )
119+ const formattedAttempt =
120+ testCaseStarted . attempt > 0 ? `, after ${ testCaseStarted . attempt + 1 } attempts` : ''
121+ this . println (
122+ indent (
123+ `${ index + 1 } ) ${ pickle . name } ${ formattedAttempt } ${ formattedLocation } ` ,
124+ GHERKIN_INDENT_LENGTH
125+ )
126+ )
127+ if ( status === TestStepResultStatus . FAILED ) {
128+ const content = formatTestStepResultError (
129+ testStepResult ,
130+ this . options . theme ,
131+ this . stream
132+ )
133+ if ( content ) {
134+ this . println ( indent ( content , GHERKIN_INDENT_LENGTH + ERROR_INDENT_LENGTH + 1 ) )
135+ this . println ( )
136+ }
116137 }
117138 }
118- } )
139+ )
119140 }
120141 }
121142 }
0 commit comments