Skip to content

Commit 5efecf9

Browse files
chore: fix problem with single tab run mode introduced by #27786 (#28032)
* chore: fix problem introduced by <pr> * Update packages/server/lib/modes/run.ts
1 parent 093d78a commit 5efecf9

File tree

1 file changed

+6
-5
lines changed
  • packages/server/lib/modes

1 file changed

+6
-5
lines changed

packages/server/lib/modes/run.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,10 @@ function waitForSocketConnection (project: Project, id: string) {
545545
})
546546
}
547547

548-
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 }) {
548+
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 }) {
549549
if (globalThis.CY_TEST_MOCK?.waitForTestsToFinishRunning) return Promise.resolve(globalThis.CY_TEST_MOCK.waitForTestsToFinishRunning)
550550

551-
const { project, screenshots, videoRecording, videoCompression, exit, spec, estimated, quiet, config, shouldKeepTabOpen, testingType, protocolManager } = options
551+
const { project, screenshots, videoRecording, videoCompression, exit, spec, estimated, quiet, config, shouldKeepTabOpen, isLastSpec, testingType, protocolManager } = options
552552

553553
const results = await listenForProjectEnd(project, exit)
554554

@@ -644,12 +644,12 @@ async function waitForTestsToFinishRunning (options: { project: Project, screens
644644
// @ts-expect-error experimentalSingleTabRunMode only exists on the CT-specific config type
645645
const usingExperimentalSingleTabMode = testingType === 'component' && config.experimentalSingleTabRunMode
646646

647-
if (usingExperimentalSingleTabMode) {
647+
if (usingExperimentalSingleTabMode && !isLastSpec) {
648648
await project.server.destroyAut()
649649
}
650650

651-
// we do not support experimentalSingleTabRunMode for e2e
652-
if (!usingExperimentalSingleTabMode) {
651+
// 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
652+
if (!usingExperimentalSingleTabMode || isLastSpec) {
653653
debug('attempting to close the browser tab')
654654

655655
await openProject.resetBrowserTabsForNextTest(shouldKeepTabOpen)
@@ -920,6 +920,7 @@ async function runSpec (config, spec: SpecWithRelativeRoot, options: { project:
920920
videoCompression: options.videoCompression,
921921
quiet: options.quiet,
922922
shouldKeepTabOpen: !isLastSpec,
923+
isLastSpec,
923924
protocolManager: options.protocolManager,
924925
}),
925926
waitForBrowserToConnect({

0 commit comments

Comments
 (0)