Skip to content

Commit 2cbc2ff

Browse files
authored
fix: fixed issue with CT + electron + run mode not exiting properly (#25585)
1 parent 8d3a6ee commit 2cbc2ff

File tree

14 files changed

+794
-6
lines changed

14 files changed

+794
-6
lines changed

cli/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ _Released 01/31/2023 (PENDING)_
55

66
**Bugfixes:**
77

8+
- Fixed a regression from Cypress 12.4.0 where Cypress was not exiting properly when running multiple Component Testing specs in `electron` in `run` mode.
9+
Fixes [#25568](https://github.com/cypress-io/cypress/issues/25568).
810
- Fixed an issue where alternative Microsoft Edge Beta and Canary binary names were not being discovered by Cypress.
911
Fixes [#25455](https://github.com/cypress-io/cypress/issues/25455).
1012

@@ -79,4 +81,4 @@ _Released 1/24/2023_
7981

8082
- Video output link in `cypress run` mode has been added to it's own line to
8183
make the video output link more easily clickable in the terminal. Addresses
82-
[#23913](https://github.com/cypress-io/cypress/issues/23913).
84+
[#23913](https://github.com/cypress-io/cypress/issues/23913).

packages/server/lib/modes/run.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ function screenshotMetadata (data, resp) {
695695
async function runSpecs (options: { config: Cfg, browser: Browser, sys: any, headed: boolean, outputPath: string, specs: SpecWithRelativeRoot[], specPattern: string | RegExp | string[], beforeSpecRun?: BeforeSpecRun, afterSpecRun?: AfterSpecRun, runUrl?: string, parallel?: boolean, group?: string, tag?: string, testingType: TestingType, quiet: boolean, project: Project, onError: (err: Error) => void, exit: boolean, socketId: string, webSecurity: boolean, projectRoot: string } & Pick<Cfg, 'video' | 'videoCompression' | 'videosFolder' | 'videoUploadOnPasses'>) {
696696
if (globalThis.CY_TEST_MOCK?.runSpecs) return globalThis.CY_TEST_MOCK.runSpecs
697697

698-
const { config, browser, sys, headed, outputPath, specs, specPattern, beforeSpecRun, afterSpecRun, runUrl, parallel, group, tag, testingType } = options
698+
const { config, browser, sys, headed, outputPath, specs, specPattern, beforeSpecRun, afterSpecRun, runUrl, parallel, group, tag } = options
699699

700700
const isHeadless = !headed
701701

@@ -814,10 +814,6 @@ async function runSpecs (options: { config: Cfg, browser: Browser, sys: any, hea
814814
})),
815815
})
816816

817-
if (testingType === 'component') {
818-
await openProject.closeBrowser()
819-
}
820-
821817
await runEvents.execute('after:run', config, moduleAPIResults)
822818
await writeOutput(outputPath, moduleAPIResults)
823819

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'cypress'
2+
3+
export default defineConfig({
4+
component: {
5+
devServer: {
6+
framework: 'react',
7+
bundler: 'vite',
8+
},
9+
},
10+
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title>Components App</title>
8+
</head>
9+
<body>
10+
<div data-cy-root></div>
11+
</body>
12+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { mount } from 'cypress/react18'
2+
3+
Cypress.Commands.add('mount', mount)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.jsx"></script>
12+
</body>
13+
</html>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "vite-simple",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "vite build",
8+
"preview": "vite preview"
9+
},
10+
"dependencies": {
11+
"react": "^18.2.0",
12+
"react-dom": "^18.2.0"
13+
},
14+
"devDependencies": {
15+
"@vitejs/plugin-react": "^3.0.1",
16+
"vite": "^4.0.4"
17+
},
18+
"type": "module"
19+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function App () {
2+
return (
3+
<h1>Hello World</h1>
4+
)
5+
}
6+
7+
export default App
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom/client'
3+
import App from './App'
4+
5+
ReactDOM.createRoot(document.getElementById('root')).render(
6+
<React.StrictMode>
7+
<App />
8+
</React.StrictMode>,
9+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import App from './App'
3+
4+
describe('<App />', () => {
5+
it('renders', () => {
6+
cy.mount(<App />)
7+
cy.contains('h1', 'Hello World')
8+
})
9+
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import App from './App'
3+
4+
describe('<App />', () => {
5+
it('renders', () => {
6+
cy.mount(<App />)
7+
cy.contains('h1', 'Hello World')
8+
})
9+
})
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from 'vite'
2+
import react from '@vitejs/plugin-react'
3+
4+
export default defineConfig({
5+
plugins: [react()],
6+
})

0 commit comments

Comments
 (0)