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

feat: adding electron support for cypress component testing #15731

Merged

Conversation

JessicaSachs
Copy link
Contributor

@JessicaSachs JessicaSachs commented Apr 1, 2021

User facing changelog

By default the Component Test Runner will launch in Electron to improve UX and maintain consistency with the E2E Runner.

Additional details

We did not support Electron in the Component Test Runner. This means that users would have needed to install Chrome on their CI machines, which isn't acceptable. Now, we support Electron, Chrome, and Firefox.

Additionally, we use Electron by default. This is a UX improvement so that there is only on system tray application.

Adding Electron support for Cypress CT revealed an issue with our logic when we destroy Electron BrowserWindows. We attempt to do so safely, but our safety checks don't prevent certain race conditions. I tried to refactor server/lib/browsers.js to make sure the instance wasn't cached so we couldn't destroy it twice, but this led to other test failures.

Rather than risk deeper breaking changes, we limited the fix so that we only tear down the browser when we're not in Electron. This behaves as expected.

How has the user experience changed?

image

  • Launch Electron by default in open-ct
  • Run mode is headless by default in run-ct

PR Tasks

  • Have tests been added/updated?
  • Has the original issue or this PR been tagged with a release in ZenHub?
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?
  • Have new configuration options been added to the cypress.schema.json?

@JessicaSachs JessicaSachs requested a review from a team as a code owner April 1, 2021 02:20
@JessicaSachs JessicaSachs requested review from chrisbreiding and kuceb and removed request for a team April 1, 2021 02:20
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 1, 2021

Thanks for taking the time to open a PR!

@JessicaSachs JessicaSachs changed the base branch from develop to electron-code-1-signal April 1, 2021 06:23
@JessicaSachs JessicaSachs force-pushed the feat/electron-support-for-component-testing branch from bb4453a to dc37ed8 Compare April 1, 2021 08:22
@flotwig flotwig force-pushed the electron-code-1-signal branch from a1acd80 to 979babe Compare April 1, 2021 15:07
@JessicaSachs JessicaSachs changed the base branch from electron-code-1-signal to 7.0-release April 1, 2021 18:12
Comment on lines 213 to 217
// instance.once('exit', () => {
// options.onBrowserClose()

return cleanup()
})
// return cleanup()
// })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? This seems important

if (!instance) {
return Promise.resolve()
}

return new Promise((resolve) => {
if (unbind) {
instance.removeAllListeners()

return resolve.apply(null, [unbind])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying to understand this change...

unbind is true only in browsers.open:

open (browser, options = {}, automation) {
return kill(true)

the resolved value appears to be irrelevant, so you could just resolve()

so the new logic is that when a browser is opened and there is an instance, instead of killing the existing browser instance, just remove all listeners from it and resolve kill?

that seems like, wrong to me... instance.kill() never even runs with this patch, i feel like that's bound to cause issues somewhere - maybe in cypress open?

and cleanup is never called with this patch, so instance will still exist

@JessicaSachs JessicaSachs force-pushed the feat/electron-support-for-component-testing branch from 2ce85e9 to 3447f2f Compare April 1, 2021 18:49
@JessicaSachs JessicaSachs force-pushed the feat/electron-support-for-component-testing branch from 3447f2f to 1701807 Compare April 1, 2021 19:16
@cypress
Copy link

cypress bot commented Apr 1, 2021



Test summary

4019 0 49 2Flakiness 0


Run details

Project cypress
Status Passed
Commit 55acc5d
Started Apr 1, 2021 9:33 PM
Ended Apr 1, 2021 9:43 PM
Duration 09:59 💡
OS Linux Debian - 10.8
Browser Chrome 89

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Contributor

@flotwig flotwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@JessicaSachs JessicaSachs merged commit 87d1318 into 7.0-release Apr 1, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 5, 2021

Released in 7.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 5, 2021
@flotwig flotwig deleted the feat/electron-support-for-component-testing branch January 24, 2022 18:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants