@@ -98,7 +98,6 @@ interface StateTestStarted {
9898 accumulation : messages . Envelope [ ] ;
9999 current : messages . Envelope [ ] ;
100100 } ;
101- testCaseStartedId : string ;
102101}
103102
104103interface StateStepStarted {
@@ -109,8 +108,6 @@ interface StateStepStarted {
109108 accumulation : messages . Envelope [ ] ;
110109 current : messages . Envelope [ ] ;
111110 } ;
112- testCaseStartedId : string ;
113- testStepStartedId : string ;
114111}
115112
116113interface StateStepFinished {
@@ -121,7 +118,6 @@ interface StateStepFinished {
121118 accumulation : messages . Envelope [ ] ;
122119 current : messages . Envelope [ ] ;
123120 } ;
124- testCaseStartedId : string ;
125121}
126122
127123interface StateTestFinished {
@@ -197,6 +193,8 @@ let state: State = {
197193
198194const isFeature = ( spec : Cypress . Spec ) => spec . name . endsWith ( ".feature" ) ;
199195
196+ const last = < E > ( col : E [ ] ) : E => col [ col . length - 1 ] ;
197+
200198const end = ( stream : stream . Writable ) =>
201199 new Promise < void > ( ( resolve ) => stream . end ( resolve ) ) ;
202200
@@ -728,10 +726,15 @@ export async function afterScreenshotHandler(
728726 return details ;
729727 }
730728
729+ const { testCaseStartedId, testStepId } = ensure (
730+ last ( state . messages . current ) . testStepStarted ,
731+ "Expected to find a testStepStarted last" ,
732+ ) ;
733+
731734 const message : messages . Envelope = {
732735 attachment : {
733- testCaseStartedId : state . testCaseStartedId ,
734- testStepId : state . testStepStartedId ,
736+ testCaseStartedId,
737+ testStepId,
735738 body : buffer . toString ( "base64" ) ,
736739 mediaType : "image/png" ,
737740 contentEncoding :
@@ -864,7 +867,6 @@ export const testCaseStartedHandler = createGracefullPluginEventHandler(
864867 accumulation : state . messages . accumulation ,
865868 current : state . messages . current . concat ( { testCaseStarted : data } ) ,
866869 } ,
867- testCaseStartedId : data . id ,
868870 } ;
869871
870872 return true ;
@@ -901,8 +903,6 @@ export const testStepStartedHandler = createGracefullPluginEventHandler(
901903 accumulation : state . messages . accumulation ,
902904 current : state . messages . current . concat ( { testStepStarted : data } ) ,
903905 } ,
904- testCaseStartedId : state . testCaseStartedId ,
905- testStepStartedId : data . testStepId ,
906906 } ;
907907
908908 return true ;
@@ -1059,7 +1059,6 @@ export const testStepFinishedHandler = createGracefullPluginEventHandler(
10591059 accumulation : state . messages . accumulation ,
10601060 current : state . messages . current . concat ( { testStepFinished } ) ,
10611061 } ,
1062- testCaseStartedId : state . testCaseStartedId ,
10631062 } ;
10641063
10651064 return true ;
@@ -1120,10 +1119,15 @@ export const createStringAttachmentHandler = createGracefullPluginEventHandler(
11201119 throw createStateError ( "createStringAttachmentHandler" , state . state ) ;
11211120 }
11221121
1122+ const { testCaseStartedId, testStepId } = ensure (
1123+ last ( state . messages . current ) . testStepStarted ,
1124+ "Expected to find a testStepStarted last" ,
1125+ ) ;
1126+
11231127 const message : messages . Envelope = {
11241128 attachment : {
1125- testCaseStartedId : state . testCaseStartedId ,
1126- testStepId : state . testStepStartedId ,
1129+ testCaseStartedId,
1130+ testStepId,
11271131 body : data ,
11281132 fileName,
11291133 mediaType : mediaType ,
0 commit comments