Skip to content

Commit 354f868

Browse files
[test optimization] Improve cypress flakiness (#6440)
1 parent 3dd8edf commit 354f868

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

integration-tests/cypress/cypress.spec.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
'use strict'
22

3+
const { promisify } = require('util')
34
const { once } = require('node:events')
45
const http = require('http')
56
const { exec, execSync } = require('child_process')
67
const path = require('path')
78
const fs = require('fs')
9+
const execPromise = promisify(exec)
810

911
const { assert } = require('chai')
1012

@@ -118,7 +120,7 @@ moduleTypes.forEach(({
118120
}
119121

120122
this.retries(2)
121-
this.timeout(60000)
123+
this.timeout(70000)
122124
let sandbox, cwd, receiver, childProcess, webAppPort, secondWebAppServer
123125

124126
if (type === 'commonJS') {
@@ -129,6 +131,11 @@ moduleTypes.forEach(({
129131
// cypress-fail-fast is required as an incompatible plugin
130132
sandbox = await createSandbox([`cypress@${version}`, 'cypress-fail-fast@7.1.0'], true)
131133
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+
132139
await new Promise(resolve => webAppServer.listen(0, 'localhost', () => {
133140
webAppPort = webAppServer.address().port
134141
resolve()
@@ -197,6 +204,8 @@ moduleTypes.forEach(({
197204

198205
receiver.assertPayloadReceived(() => {
199206
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')
200209
done(error)
201210
}, ({ url }) => url.endsWith('/api/v2/citestcycle')).catch(() => {})
202211

@@ -222,23 +231,21 @@ moduleTypes.forEach(({
222231
testOutput += chunk.toString()
223232
})
224233

225-
// TODO: remove once we find the source of flakiness
226-
childProcess.stdout.pipe(process.stdout)
227-
childProcess.stderr.pipe(process.stderr)
228-
229234
childProcess.on('exit', () => {
230235
assert.notInclude(testOutput, 'TypeError')
231236
// TODO: remove try/catch once we find the source of flakiness
232237
try {
233238
assert.include(testOutput, '1 of 1 failed')
239+
done()
234240
} catch (e) {
235241
// eslint-disable-next-line no-console
236242
console.log('---- Actual test output -----')
237243
// eslint-disable-next-line no-console
238244
console.log(testOutput)
239-
throw e
245+
// eslint-disable-next-line no-console
246+
console.log('---- finish actual test output -----')
247+
done(e)
240248
}
241-
done()
242249
})
243250
})
244251

0 commit comments

Comments
 (0)