Skip to content

Commit a8262ef

Browse files
committed
reorder cck envelopes to pass
1 parent 0d37641 commit a8262ef

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

compatibility/cck_spec.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,45 @@ describe('Cucumber Compatibility Kit', () => {
100100
})
101101
)
102102

103-
expect(actualMessages)
103+
expect(reorderEnvelopes(actualMessages))
104104
.excludingEvery(ignorableKeys)
105105
.to.deep.eq(expectedMessages)
106106
})
107107
}
108108
})
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

Comments
 (0)