@@ -17,8 +17,6 @@ const CCK_FEATURES_PATH = 'node_modules/@cucumber/compatibility-kit/features'
1717const CCK_IMPLEMENTATIONS_PATH = 'compatibility/features'
1818
1919const UNSUPPORTED = [
20- // we don't support global hooks messages yet
21- 'global-hooks' ,
2220 'global-hooks-attachments' ,
2321 'global-hooks-beforeall-error' ,
2422 'global-hooks-afterall-error' ,
@@ -102,9 +100,45 @@ describe('Cucumber Compatibility Kit', () => {
102100 } )
103101 )
104102
105- expect ( actualMessages )
103+ expect ( reorderEnvelopes ( actualMessages ) )
106104 . excludingEvery ( ignorableKeys )
107105 . to . deep . eq ( expectedMessages )
108106 } )
109107 }
110108} )
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+ }
0 commit comments