Skip to content

Commit 12a8db4

Browse files
committed
Attempt to fix
1 parent f71536b commit 12a8db4

File tree

7 files changed

+40
-5
lines changed

7 files changed

+40
-5
lines changed

circle.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,6 @@ jobs:
11951195
browser: chrome
11961196
package: launchpad
11971197
type: ct
1198-
debug: cypress:*,engine:socket
11991198

12001199
run-launchpad-integration-tests-chrome:
12011200
<<: *defaults

packages/server/lib/modes/run.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,11 +1046,16 @@ module.exports = {
10461046
return this.currentWriteVideoFrameCallback(...arguments)
10471047
},
10481048

1049-
waitForBrowserToConnect (options = {}, shouldLaunchBrowser = true) {
1049+
waitForBrowserToConnect (options = {}, isFirstSpec = false) {
10501050
const { project, socketId, timeout, onError, writeVideoFrame, spec } = options
10511051
const browserTimeout = process.env.CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT || timeout || 60000
10521052
let attempts = 0
10531053

1054+
const shouldLaunchBrowser = project.shouldLaunchBrowser || isFirstSpec
1055+
1056+
// Reset to e2e only once we've gotten the state for this run
1057+
project.shouldLaunchBrowser = options.testingType === 'e2e'
1058+
10541059
// short circuit current browser callback so that we
10551060
// can rewire it without relaunching the browser
10561061
if (writeVideoFrame) {
@@ -1081,6 +1086,12 @@ module.exports = {
10811086
return Promise.resolve(this.navigateToNextSpec(options.spec))
10821087
}
10831088

1089+
if (!project.shouldLaunchBrowser) {
1090+
project.on('socket:disconnect', () => {
1091+
project.shouldLaunchBrowser = true
1092+
})
1093+
}
1094+
10841095
return Promise.join(
10851096
this.waitForSocketConnection(project, socketId)
10861097
.tap(() => {
@@ -1406,6 +1417,8 @@ module.exports = {
14061417
runSpec (config, spec = {}, options = {}, estimated, firstSpec) {
14071418
const { project, browser, onError } = options
14081419

1420+
project.shouldLaunchBrowser = options.testingType === 'e2e'
1421+
14091422
const { isHeadless } = browser
14101423

14111424
debug('about to run spec %o', {
@@ -1464,7 +1477,7 @@ module.exports = {
14641477
socketId: options.socketId,
14651478
webSecurity: options.webSecurity,
14661479
projectRoot: options.projectRoot,
1467-
}, options.testingType === 'e2e' || firstSpec),
1480+
}, firstSpec),
14681481
})
14691482
})
14701483
},

packages/server/lib/project-base.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,11 @@ export class ProjectBase<TServer extends Server> extends EE {
611611
this.emit('socket:connected', id)
612612
},
613613

614+
onDisconnect: () => {
615+
debug('socket:disconnect')
616+
this.emit('socket:disconnect')
617+
},
618+
614619
onTestsReceivedAndMaybeRecord: async (runnables: unknown[], cb: () => void) => {
615620
debug('received runnables %o', runnables)
616621

packages/server/lib/socket-base.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export class SocketBase {
146146
onTestsReceivedAndMaybeRecord () {},
147147
onMocha () {},
148148
onConnect () {},
149+
onDisconnect () {},
149150
onRequest () {},
150151
onResolveUrl () {},
151152
onFocusTests () {},
@@ -186,7 +187,10 @@ export class SocketBase {
186187

187188
const getFixture = (path, opts) => fixture.get(config.fixturesFolder, path, opts)
188189

189-
this.io.on('connection', (socket: Socket & { inReporterRoom?: boolean }) => {
190+
this.io.on('connection', (socket: Socket & {
191+
inRunnerRoom?: boolean
192+
inReporterRoom?: boolean
193+
}) => {
190194
debug('socket connected')
191195

192196
socket.on('disconnecting', (reason) => {
@@ -195,6 +199,7 @@ export class SocketBase {
195199

196200
socket.on('disconnect', (reason) => {
197201
debug(`socket-disconnect ${reason}`)
202+
options.onDisconnect(reason)
198203
})
199204

200205
socket.on('error', (err) => {

scripts/gulp/gulpConstants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const ENV_VARS = {
4545
interface GulpGlobalVals {
4646
debug?: Maybe<'--inspect' | '--inspect-brk'>
4747
shouldWatch?: boolean
48+
mode?: 'open' | 'run-ct'
4849
}
4950

5051
const globalVals: GulpGlobalVals = {

scripts/gulp/gulpfile.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ gulp.task(
7777
),
7878
)
7979

80+
gulp.task(
81+
'debug:run',
82+
gulp.series(
83+
async function setupDebugRun () {
84+
setGulpGlobal('debug', '--inspect')
85+
setGulpGlobal('mode', 'run-ct')
86+
},
87+
'dev',
88+
),
89+
)
90+
8091
gulp.task(
8192
'debugBrk',
8293
gulp.series(

scripts/gulp/tasks/gulpCypress.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ async function spawnCypressWithMode (
142142
*------------------------------------------------------------------------**/
143143

144144
export async function startCypressWatch () {
145+
const mode = getGulpGlobal('mode') ?? 'open'
145146
const watcher = chokidar.watch([
146147
'packages/{graphql,data-context}/src/**/*.{js,ts}',
147148
'packages/server/lib/graphql/**/*.{js,ts}',
@@ -156,7 +157,7 @@ export async function startCypressWatch () {
156157
let child: ChildProcess | null = null
157158

158159
async function startCypressWithListeners () {
159-
child = await spawnCypressWithMode('open', 'dev', ENV_VARS.DEV)
160+
child = await spawnCypressWithMode(mode, 'dev', ENV_VARS.DEV)
160161

161162
child.on('exit', (code) => {
162163
if (isClosing) {

0 commit comments

Comments
 (0)