@@ -120,7 +120,7 @@ moduleTypes.forEach(({
120
120
}
121
121
122
122
this . retries ( 2 )
123
- this . timeout ( 70000 )
123
+ this . timeout ( 80000 )
124
124
let sandbox , cwd , receiver , childProcess , webAppPort , secondWebAppServer
125
125
126
126
if ( type === 'commonJS' ) {
@@ -195,21 +195,20 @@ moduleTypes.forEach(({
195
195
} )
196
196
}
197
197
198
- it ( 'does not crash if badly init' , ( done ) => {
198
+ it ( 'does not crash if badly init' , async ( ) => {
199
199
const {
200
200
NODE_OPTIONS , // NODE_OPTIONS dd-trace config does not work with cypress
201
201
DD_CIVISIBILITY_AGENTLESS_URL ,
202
202
...restEnvVars
203
203
} = getCiVisAgentlessConfig ( receiver . port )
204
204
205
- receiver . assertPayloadReceived ( ( ) => {
206
- const error = new Error ( 'it should not report test events' )
207
- // eslint-disable-next-line no-console
208
- console . log ( 'it should never be executed' )
209
- done ( error )
205
+ let hasReceivedEvents = false
206
+
207
+ const eventsPromise = receiver . assertPayloadReceived ( ( ) => {
208
+ hasReceivedEvents = true
210
209
} , ( { url } ) => url . endsWith ( '/api/v2/citestcycle' ) ) . catch ( ( ) => { } )
211
210
212
- let testOutput
211
+ let testOutput = ''
213
212
214
213
childProcess = exec (
215
214
testCommand ,
@@ -231,22 +230,27 @@ moduleTypes.forEach(({
231
230
testOutput += chunk . toString ( )
232
231
} )
233
232
234
- childProcess . on ( 'exit' , ( ) => {
233
+ await Promise . all ( [
234
+ once ( childProcess . stdout , 'end' ) ,
235
+ once ( childProcess . stderr , 'end' ) ,
236
+ once ( childProcess , 'exit' ) ,
237
+ eventsPromise
238
+ ] )
239
+
240
+ assert . strictEqual ( hasReceivedEvents , false )
241
+ // TODO: remove try/catch once we find the source of flakiness
242
+ try {
235
243
assert . notInclude ( testOutput , 'TypeError' )
236
- // TODO: remove try/catch once we find the source of flakiness
237
- try {
238
- assert . include ( testOutput , '1 of 1 failed' )
239
- done ( )
240
- } catch ( e ) {
241
- // eslint-disable-next-line no-console
242
- console . log ( '---- Actual test output -----' )
243
- // eslint-disable-next-line no-console
244
- console . log ( testOutput )
245
- // eslint-disable-next-line no-console
246
- console . log ( '---- finish actual test output -----' )
247
- done ( e )
248
- }
249
- } )
244
+ assert . include ( testOutput , '1 of 1 failed' )
245
+ } catch ( e ) {
246
+ // eslint-disable-next-line no-console
247
+ console . log ( '---- Actual test output -----' )
248
+ // eslint-disable-next-line no-console
249
+ console . log ( testOutput )
250
+ // eslint-disable-next-line no-console
251
+ console . log ( '---- finish actual test output -----' )
252
+ throw e
253
+ }
250
254
} )
251
255
252
256
it ( 'catches errors in hooks' , ( done ) => {
0 commit comments