File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -100,9 +100,45 @@ describe('Cucumber Compatibility Kit', () => {
100
100
} )
101
101
)
102
102
103
- expect ( actualMessages )
103
+ expect ( reorderEnvelopes ( actualMessages ) )
104
104
. excludingEvery ( ignorableKeys )
105
105
. to . deep . eq ( expectedMessages )
106
106
} )
107
107
}
108
108
} )
109
+
110
+ function reorderEnvelopes (
111
+ envelopes : ReadonlyArray < Envelope >
112
+ ) : ReadonlyArray < Envelope > {
113
+ let testRunStartedEnvelope : Envelope
114
+ let testCaseStartedEnvelope : Envelope
115
+
116
+ const result : Envelope [ ] = [ ]
117
+ const moveAfterTestRunStarted : Envelope [ ] = [ ]
118
+
119
+ for ( const envelope of envelopes ) {
120
+ if ( envelope . testRunStarted ) {
121
+ testRunStartedEnvelope = envelope
122
+ }
123
+ if ( envelope . testCaseStarted ) {
124
+ testCaseStartedEnvelope = envelope
125
+ }
126
+
127
+ if (
128
+ ( envelope . testRunHookStarted || envelope . testRunHookFinished ) &&
129
+ ! testCaseStartedEnvelope
130
+ ) {
131
+ moveAfterTestRunStarted . push ( envelope )
132
+ } else {
133
+ result . push ( envelope )
134
+ }
135
+ }
136
+
137
+ result . splice (
138
+ result . indexOf ( testRunStartedEnvelope ) + 1 ,
139
+ 0 ,
140
+ ...moveAfterTestRunStarted
141
+ )
142
+
143
+ return result
144
+ }
You can’t perform that action at this time.
0 commit comments