@@ -179,6 +179,7 @@ class MyReporter {
179
179
debug ( `Exception in populating test data for hook skipped test with error : ${ err } ` , true , err ) ;
180
180
}
181
181
182
+ await this . uploadTestSteps ( ) ;
182
183
await requestQueueHandler . shutdown ( ) ;
183
184
} ) ;
184
185
}
@@ -224,14 +225,14 @@ class MyReporter {
224
225
}
225
226
}
226
227
227
- uploadTestSteps = async ( test_run_uuid = null , hook_run_uuid = null , shouldClearCurrentSteps = true , cypressSteps = null ) => {
228
+ uploadTestSteps = async ( shouldClearCurrentSteps = true , cypressSteps = null ) => {
228
229
const currentTestSteps = cypressSteps ? cypressSteps : JSON . parse ( JSON . stringify ( this . currentTestSteps ) ) ;
229
230
/* TODO - Send as test logs */
230
231
const allStepsAsLogs = [ ] ;
231
232
currentTestSteps . forEach ( step => {
232
233
const currentStepAsLog = {
233
- test_run_uuid,
234
- hook_run_uuid,
234
+ test_run_uuid : step . test_run_uuid ,
235
+ hook_run_uuid : step . hook_run_uuid ,
235
236
timestamp : step . started_at ,
236
237
level : step . result ,
237
238
message : step . text ,
@@ -240,7 +241,6 @@ class MyReporter {
240
241
} ;
241
242
allStepsAsLogs . push ( currentStepAsLog ) ;
242
243
} ) ;
243
- if ( currentTestSteps . length ) consoleHolder . log ( `\n SENDING BELOW STEPS FOR Test = ${ test_run_uuid } OR Hook = ${ hook_run_uuid } \n ${ JSON . stringify ( currentTestSteps , 0 , 3 ) } \n` ) ;
244
244
await uploadEventData ( {
245
245
event_type : 'LogCreated' ,
246
246
logs : allStepsAsLogs
@@ -396,10 +396,8 @@ class MyReporter {
396
396
} else {
397
397
await uploadEventData ( uploadData ) ;
398
398
399
- if ( eventType == 'HookRunFinished' ) {
400
- await this . uploadTestSteps ( null , testData [ 'uuid' ] ) ;
401
- } else if ( eventType == 'TestRunFinished' ) {
402
- await this . uploadTestSteps ( testData [ 'uuid' ] ) ;
399
+ if ( eventType . match ( / F i n i s h e d / ) ) {
400
+ await this . uploadTestSteps ( ) ;
403
401
}
404
402
405
403
if ( eventType . match ( / T e s t R u n / ) ) {
@@ -408,7 +406,7 @@ class MyReporter {
408
406
delete hookUploadObj . cypressSteps ;
409
407
hookUploadObj [ 'hook_run' ] [ 'test_run_id' ] = test . testAnalyticsId ;
410
408
await uploadEventData ( hookUploadObj ) ;
411
- await this . uploadTestSteps ( null , hookUploadObj [ 'hook_run' ] [ 'uuid' ] , false , currentTestSteps ) ;
409
+ await this . uploadTestSteps ( false , currentTestSteps ) ;
412
410
} ) ;
413
411
this . beforeHooks = [ ] ;
414
412
}
@@ -544,16 +542,20 @@ class MyReporter {
544
542
return ;
545
543
}
546
544
545
+ const currentStepObj = {
546
+ id : command . attributes . id ,
547
+ text : 'cy.' + command . attributes . name + '(' + this . getFormattedArgs ( command . attributes . args ) + ')' ,
548
+ started_at : new Date ( ) . toISOString ( ) ,
549
+ finished_at : null ,
550
+ duration : null ,
551
+ result : 'pending' ,
552
+ test_run_uuid : this . current_test ?. testAnalyticsId && ! this . runStatusMarkedHash [ this . current_test . testAnalyticsId ] ? this . current_test . testAnalyticsId : null ,
553
+ hook_run_uuid : this . current_hook ?. hookAnalyticsId && ! this . runStatusMarkedHash [ this . current_hook . hookAnalyticsId ] ? this . current_hook . hookAnalyticsId : null
554
+ } ;
555
+ if ( currentStepObj . hook_run_uuid && currentStepObj . test_run_uuid ) delete currentStepObj . test_run_uuid ;
547
556
this . currentTestSteps = [
548
557
...this . currentTestSteps ,
549
- {
550
- id : command . attributes . id ,
551
- text : 'cy.' + command . attributes . name + '(' + this . getFormattedArgs ( command . attributes . args ) + ')' ,
552
- started_at : new Date ( ) . toISOString ( ) ,
553
- finished_at : null ,
554
- duration : null ,
555
- result : 'pending'
556
- }
558
+ currentStepObj
557
559
] ;
558
560
} else if ( type == 'COMMAND_END' ) {
559
561
let stepUpdated = false ;
@@ -571,16 +573,20 @@ class MyReporter {
571
573
572
574
if ( ! stepUpdated ) {
573
575
/* COMMAND_END reported before COMMAND_START */
576
+ const currentStepObj = {
577
+ id : command . attributes . id ,
578
+ text : 'cy.' + command . attributes . name + '(' + this . getFormattedArgs ( command . attributes . args ) + ')' ,
579
+ started_at : new Date ( ) . toISOString ( ) ,
580
+ finished_at : new Date ( ) . toISOString ( ) ,
581
+ duration : 0 ,
582
+ result : command . state ,
583
+ test_run_uuid : this . current_test ?. testAnalyticsId && ! this . runStatusMarkedHash [ this . current_test . testAnalyticsId ] ? this . current_test . testAnalyticsId : null ,
584
+ hook_run_uuid : this . current_hook ?. hookAnalyticsId && ! this . runStatusMarkedHash [ this . current_hook . hookAnalyticsId ] ? this . current_hook . hookAnalyticsId : null
585
+ } ;
586
+ if ( currentStepObj . hook_run_uuid && currentStepObj . test_run_uuid ) delete currentStepObj . test_run_uuid ;
574
587
this . currentTestSteps = [
575
588
...this . currentTestSteps ,
576
- {
577
- id : command . attributes . id ,
578
- text : 'cy.' + command . attributes . name + '(' + this . getFormattedArgs ( command . attributes . args ) + ')' ,
579
- started_at : new Date ( ) . toISOString ( ) ,
580
- finished_at : new Date ( ) . toISOString ( ) ,
581
- duration : 0 ,
582
- result : command . state
583
- }
589
+ currentStepObj
584
590
] ;
585
591
}
586
592
} else if ( type == 'COMMAND_RETRY' ) {
0 commit comments