-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix(server): use run#run instead of run#ready to replicate e2e exit behavior in CT #17894
fix(server): use run#run instead of run#ready to replicate e2e exit behavior in CT #17894
Conversation
Thanks for taking the time to open a PR!
|
@@ -20,7 +20,7 @@ const run = (options) => { | |||
// if we're in run mode with component | |||
// testing then just pass this through | |||
// without waiting on electron to be ready | |||
return require('./run').ready(options) | |||
return require('./run').run(options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now match run-e2e.js
: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/modes/run-e2e.js#L2
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what specifically in electron causes this problem. Even looking at the diff above in electron versions, I am not sure why.
Me either, after reviewing the diff, I can tell that it changes some window-related behavior, so maybe what triggered this bug to pop up is a change in the timing characteristics of when windows-all-closed
is fired.
I'm trying to apply this patch in node_modules/ of my installed version of 8.3.0 to test it, and cannot find any files with the comment, or |
User facing changelog
Fix a bug where correct exit code is not propagated when using
run-ct
with the bundled electron browser (13.x).Additional details
See these posts for my original debugging. A regression was introduced when we updated to electron 12.x to 13.x. This was release in Cypress 8.3.
When running
run-ct
, even when tests fail, we wouldexit(0)
, instead ofexit(num_failed_tests)
. This means your CI would always be green. This only happens when runningrun-ct
using the bundled electron browser.The specific electron version that introduced this problem was between
[email protected]
->[email protected]
. Diff is here: electron/electron@v13.0.0-beta.27...v13.0.0-beta.28. You will notice if you check outcypress@develop
and use13.0.0-beta.27
for electron, everything is okay, but if you update to13.0.0-beta.28
, it regresses.I don't know what specifically in electron causes this problem. Even looking at the diff above in electron versions, I am not sure why.
Either way, there is a fix.
run
andrun-ct
take slightly different paths.run
callsrun#run
(which callsrun#ready
).run-ct
skipsrun#run
and goes straight torun#ready
.By doing this, this critical part is skipped.
This appears to do nothing at all on first inspection. If we look at the electron docs...
My understanding is by calling
run#ready
and bypassingrun#run
(which basically just subscribes towindow-all-closed
then callsrun#run
, we end up invoking the default behavior of the electron browser, which is to quit the app (with exit code 0).By subscribing, we control whether the app quits or not. We use this control to quit with a specific exit code, which is the number of failed specs.
Again, this should been a problem in the past too - I'm not clear on why it only starting causing problems after the electron 13 upgrade.
Testing
We do not have many e2e tests around
run-ct
. It uses 99% of the same code as e2e, but the 1% is where the bug was. I modified thee2e
test harness slightly and added one that correctly catches this regression.You can also reproduce and test the bug fix as follows:
develop
, create a failing spec inrunner-ct/cypress/components
cd packages/runner-ct && yarn cypress:run
(launches CT in run mode w/ electron)You can also revert the electron version 12.x in develop and you'll notice the problem goes away.
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?