1
1
'use strict'
2
2
3
+ const { promisify } = require ( 'util' )
3
4
const { once } = require ( 'node:events' )
4
5
const http = require ( 'http' )
5
6
const { exec, execSync } = require ( 'child_process' )
6
7
const path = require ( 'path' )
7
8
const fs = require ( 'fs' )
9
+ const execPromise = promisify ( exec )
8
10
9
11
const { assert } = require ( 'chai' )
10
12
@@ -118,7 +120,7 @@ moduleTypes.forEach(({
118
120
}
119
121
120
122
this . retries ( 2 )
121
- this . timeout ( 60000 )
123
+ this . timeout ( 70000 )
122
124
let sandbox , cwd , receiver , childProcess , webAppPort , secondWebAppServer
123
125
124
126
if ( type === 'commonJS' ) {
@@ -129,6 +131,11 @@ moduleTypes.forEach(({
129
131
// cypress-fail-fast is required as an incompatible plugin
130
132
sandbox = await createSandbox ( [ `cypress@${ version } ` , 'cypress-fail-fast@7.1.0' ] , true )
131
133
cwd = sandbox . folder
134
+
135
+ const { NODE_OPTIONS , ...restOfEnv } = process . env
136
+ // Install cypress' browser before running the tests
137
+ await execPromise ( 'npx cypress install' , { cwd, env : restOfEnv , stdio : 'inherit' } )
138
+
132
139
await new Promise ( resolve => webAppServer . listen ( 0 , 'localhost' , ( ) => {
133
140
webAppPort = webAppServer . address ( ) . port
134
141
resolve ( )
@@ -197,6 +204,8 @@ moduleTypes.forEach(({
197
204
198
205
receiver . assertPayloadReceived ( ( ) => {
199
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' )
200
209
done ( error )
201
210
} , ( { url } ) => url . endsWith ( '/api/v2/citestcycle' ) ) . catch ( ( ) => { } )
202
211
@@ -222,23 +231,21 @@ moduleTypes.forEach(({
222
231
testOutput += chunk . toString ( )
223
232
} )
224
233
225
- // TODO: remove once we find the source of flakiness
226
- childProcess . stdout . pipe ( process . stdout )
227
- childProcess . stderr . pipe ( process . stderr )
228
-
229
234
childProcess . on ( 'exit' , ( ) => {
230
235
assert . notInclude ( testOutput , 'TypeError' )
231
236
// TODO: remove try/catch once we find the source of flakiness
232
237
try {
233
238
assert . include ( testOutput , '1 of 1 failed' )
239
+ done ( )
234
240
} catch ( e ) {
235
241
// eslint-disable-next-line no-console
236
242
console . log ( '---- Actual test output -----' )
237
243
// eslint-disable-next-line no-console
238
244
console . log ( testOutput )
239
- throw e
245
+ // eslint-disable-next-line no-console
246
+ console . log ( '---- finish actual test output -----' )
247
+ done ( e )
240
248
}
241
- done ( )
242
249
} )
243
250
} )
244
251
0 commit comments