From 5efecf9a4a72fbb0199a23917623218b843bd97c Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Wed, 11 Oct 2023 12:36:21 -0500 Subject: [PATCH] chore: fix problem with single tab run mode introduced by #27786 (#28032) * chore: fix problem introduced by * Update packages/server/lib/modes/run.ts --- packages/server/lib/modes/run.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/server/lib/modes/run.ts b/packages/server/lib/modes/run.ts index 2dbee21338a6..77719b283b4d 100644 --- a/packages/server/lib/modes/run.ts +++ b/packages/server/lib/modes/run.ts @@ -545,10 +545,10 @@ function waitForSocketConnection (project: Project, id: string) { }) } -async function waitForTestsToFinishRunning (options: { project: Project, screenshots: ScreenshotMetadata[], videoCompression: number | boolean, exit: boolean, spec: SpecWithRelativeRoot, estimated: number, quiet: boolean, config: Cfg, shouldKeepTabOpen: boolean, testingType: TestingType, videoRecording?: VideoRecording, protocolManager?: ProtocolManager }) { +async function waitForTestsToFinishRunning (options: { project: Project, screenshots: ScreenshotMetadata[], videoCompression: number | boolean, exit: boolean, spec: SpecWithRelativeRoot, estimated: number, quiet: boolean, config: Cfg, shouldKeepTabOpen: boolean, isLastSpec: boolean, testingType: TestingType, videoRecording?: VideoRecording, protocolManager?: ProtocolManager }) { if (globalThis.CY_TEST_MOCK?.waitForTestsToFinishRunning) return Promise.resolve(globalThis.CY_TEST_MOCK.waitForTestsToFinishRunning) - const { project, screenshots, videoRecording, videoCompression, exit, spec, estimated, quiet, config, shouldKeepTabOpen, testingType, protocolManager } = options + const { project, screenshots, videoRecording, videoCompression, exit, spec, estimated, quiet, config, shouldKeepTabOpen, isLastSpec, testingType, protocolManager } = options const results = await listenForProjectEnd(project, exit) @@ -644,12 +644,12 @@ async function waitForTestsToFinishRunning (options: { project: Project, screens // @ts-expect-error experimentalSingleTabRunMode only exists on the CT-specific config type const usingExperimentalSingleTabMode = testingType === 'component' && config.experimentalSingleTabRunMode - if (usingExperimentalSingleTabMode) { + if (usingExperimentalSingleTabMode && !isLastSpec) { await project.server.destroyAut() } - // we do not support experimentalSingleTabRunMode for e2e - if (!usingExperimentalSingleTabMode) { + // we do not support experimentalSingleTabRunMode for e2e. We always want to close the tab on the last spec to ensure that things get cleaned up properly at the end of the run + if (!usingExperimentalSingleTabMode || isLastSpec) { debug('attempting to close the browser tab') await openProject.resetBrowserTabsForNextTest(shouldKeepTabOpen) @@ -920,6 +920,7 @@ async function runSpec (config, spec: SpecWithRelativeRoot, options: { project: videoCompression: options.videoCompression, quiet: options.quiet, shouldKeepTabOpen: !isLastSpec, + isLastSpec, protocolManager: options.protocolManager, }), waitForBrowserToConnect({