@@ -12,6 +12,7 @@ import type {
1212 Task ,
1313 TaskMeta ,
1414 TaskResult ,
15+ TaskResultAttempt ,
1516 TaskResultPack ,
1617 TaskState ,
1718 TaskUpdateEvent ,
@@ -599,6 +600,7 @@ async function runTest(test: Test, runner: VitestRunner): Promise<void> {
599600 state : 'run' ,
600601 startTime : unixNow ( ) ,
601602 retryCount : 0 ,
603+ attempts : [ ] ,
602604 }
603605 updateTask ( 'test-prepare' , test , runner )
604606
@@ -615,7 +617,20 @@ async function runTest(test: Test, runner: VitestRunner): Promise<void> {
615617 test . result . state = 'run' as TaskState
616618 const retry = getRetryCount ( test . retry )
617619 for ( let retryCount = 0 ; retryCount <= retry ; retryCount ++ ) {
620+ const attemptStart = now ( )
621+ const attemptStartTime = unixNow ( )
618622 const attemptErrorsStart = test . result . errors ?. length ?? 0
623+ const recordAttempt = ( state : TaskResultAttempt [ 'state' ] ) => {
624+ const errors = test . result ! . errors ?. slice ( attemptErrorsStart )
625+ test . result ! . attempts ! . push ( {
626+ state,
627+ errors : errors ?. length ? errors : undefined ,
628+ duration : now ( ) - attemptStart ,
629+ startTime : attemptStartTime ,
630+ retryIndex : retryCount ,
631+ repeatIndex : repeatCount ,
632+ } )
633+ }
619634 const beforeEachCleanups : unknown [ ] = [ ]
620635 // fixtureCheckpoint is passed by callAroundEachHooks - it represents the count
621636 // of fixture cleanup functions AFTER all aroundEach fixtures have been resolved
@@ -714,12 +729,14 @@ async function runTest(test: Test, runner: VitestRunner): Promise<void> {
714729
715730 // skipped with new PendingError
716731 if ( test . result ?. pending || test . result ?. state === 'skip' ) {
732+ recordAttempt ( 'skip' )
717733 test . mode = 'skip'
718734 test . result = {
719735 state : 'skip' ,
720736 note : test . result ?. note ,
721737 pending : true ,
722738 duration : now ( ) - start ,
739+ attempts : test . result . attempts ,
723740 }
724741 updateTask ( 'test-finished' , test , runner )
725742 setCurrentTest ( undefined )
@@ -744,6 +761,7 @@ async function runTest(test: Test, runner: VitestRunner): Promise<void> {
744761 }
745762 }
746763 }
764+ recordAttempt ( test . result . state === 'pass' ? 'pass' : 'fail' )
747765 if ( test . result . state === 'pass' ) {
748766 break
749767 }
0 commit comments