@@ -17,8 +17,6 @@ const CCK_FEATURES_PATH = 'node_modules/@cucumber/compatibility-kit/features'
17
17
const CCK_IMPLEMENTATIONS_PATH = 'compatibility/features'
18
18
19
19
const UNSUPPORTED = [
20
- // we don't support global hooks messages yet
21
- 'global-hooks' ,
22
20
'global-hooks-attachments' ,
23
21
'global-hooks-beforeall-error' ,
24
22
'global-hooks-afterall-error' ,
@@ -102,9 +100,45 @@ describe('Cucumber Compatibility Kit', () => {
102
100
} )
103
101
)
104
102
105
- expect ( actualMessages )
103
+ expect ( reorderEnvelopes ( actualMessages ) )
106
104
. excludingEvery ( ignorableKeys )
107
105
. to . deep . eq ( expectedMessages )
108
106
} )
109
107
}
110
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
+ }
0 commit comments