Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix problem with single tab run mode introduced by #27786 #28032

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/server/lib/modes/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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({
Expand Down
Loading