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

fix(regression): cy.pause() should not be ignored with cypress run --headed --no-exit #20877

Merged
merged 19 commits into from Apr 11, 2022

Conversation

davidmunechika
Copy link
Contributor

@davidmunechika davidmunechika commented Apr 1, 2022

User facing changelog

Fixes a regression that was introduced by this PR which prevented cy.pause() from correctly executing when run with cypress run --headed --no-exit.

Additional details

Original implementation PR: #18358

The cause of this regression was the addition of exit to ResolvedConfigOptions in this PR. As a result, when the args got merged with the config, config('exit') would always be true even when --no-exit was passed. When this change was made, we should have removed this line

However, it was decided that exit should be an arg that is not included as part of config. Therefore, this PR removes exit from the ResolvedConfigOptions and correctly passes exit through the options so no conflicts will occur with the config and --no-exit will still work as expected.

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [n/a] Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?
  • [n/a] Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 1, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Apr 1, 2022



Test summary

19391 0 218 0Flakiness 2


Run details

Project cypress
Status Passed
Commit 42ef9ab
Started Apr 11, 2022 3:29 PM
Ended Apr 11, 2022 3:41 PM
Duration 11:58 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

commands/xhr_spec.js Flakiness
1 ... > no status when request isnt forced 404
cypress/proxy-logging_spec.ts Flakiness
1 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second

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

@davidmunechika davidmunechika marked this pull request as ready for review April 5, 2022 22:13
@davidmunechika davidmunechika requested review from a team as code owners April 5, 2022 22:13
@davidmunechika davidmunechika requested review from jennifer-shehane, flotwig and emilyrohrbough and removed request for a team and jennifer-shehane April 5, 2022 22:13
name: 'exit',
defaultValue: true,
validation: validate.isBoolean,
canUpdateDuringTestTime: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does removing this fix the issue? 🤔

Do you mind explaining a little more about this fixed the regression (not entirely clear what part of the regression PR linked broke this in the first place).

Is the bug actually caused by the unique combo of --headed and --no-exit, or is it just related to one of those flags? Looking at the snippet in the related issue:

if (!config('isInteractive') && (!config('browser').isHeaded || config('exit'))) {

Seems it's one or the other (which means we'd probably want two system tests, one with each condition).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lmiller1990 I've updated this PR description with more details about the regression. The expected behavior is that Cypress will pause if it is in open mode or if it in run mode with --headed and --no-exit both passed as args. Therefore, if cypress is in run mode aka not interactive (!config('isInteractive')) and either --headed or --no-exit was not passed, then we do not want to pause. Hence, the logic in the snippet above

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I see! I hope we can have config('mode') in the future - config('mode') === 'run would be way more readable. Nice job hunting down this regression.

lmiller1990
lmiller1990 previously approved these changes Apr 7, 2022
Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

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

Seems fine - I had my comment clarified, also left one final question but happy to drop the ✔️ since the regression is fixed w/ a test.

spec: 'pause_simple_spec.js',
snapshot: false,
headed: true,
noExit: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Somewhat surprised a test can have an exit code of 0 and have noExit as true - seems like these would conflict, but seems this isn't the case?

Copy link
Contributor

Choose a reason for hiding this comment

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

At least locally this seems to hang forever (on develop, was verifying it fails there)

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this test is still a wip- it will hang forever because --no-exit has been passed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently working on adding a callback to ExecOptions (something like onSpawn) that yields the ChildProcess so we can listen to the stdout and kill the ChildProcess within the system test itself when not exiting due to options.exit being false gets logged.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, can you mark it as draft? I can re-review when you are happy with it - I thought this was ready for review - click "Still in progress - mark as draft" under reviewers (kind of new feature on GH, some ppl haven't seen it).

image

@davidmunechika davidmunechika marked this pull request as draft April 7, 2022 01:15
@davidmunechika davidmunechika self-assigned this Apr 7, 2022
@davidmunechika davidmunechika marked this pull request as ready for review April 7, 2022 21:22
emilyrohrbough
emilyrohrbough previously approved these changes Apr 7, 2022
Copy link
Member

@emilyrohrbough emilyrohrbough left a comment

Choose a reason for hiding this comment

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

🎉 Nice!! Glad you got this figured out. At this point are the existing driver tests around this behavior helpful and/or should those test cases be updated as well?

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.

Nice work on the clean fix for this, and on the new test coverage for --no-exit. I was really surprised that we have no coverage considering it's part of our public API.

system-tests/lib/system-tests.ts Outdated Show resolved Hide resolved
system-tests/lib/system-tests.ts Outdated Show resolved Hide resolved
system-tests/test/pause_headed_exit_spec.ts Show resolved Hide resolved
Co-authored-by: Emily Rohrbough  <emilyrohrbough@users.noreply.github.com>
system-tests/lib/docker.ts Outdated Show resolved Hide resolved
@davidmunechika davidmunechika merged commit 6934c03 into develop Apr 11, 2022
@davidmunechika davidmunechika deleted the issue-20745-pause-headed-regression branch April 11, 2022 17:25
tgriesser added a commit that referenced this pull request Apr 14, 2022
* 10.0-release: (25 commits)
  fix: stop running spec when switching specs (#21038)
  fix: remove asset size warnings and enable nuxt e2e tests (#21074)
  feat: swap the #__cy_root id selector to become data-cy-root for component mounting (#20951)
  fix: Doc changes around vue2 (#21066)
  feat: Add vue2 package from npm/vue/v2 branch (#21026)
  skip failing test
  fix: add possible frameworks to object API config (#21056)
  fix snapshot spacing
  fix system test
  fix snapshot
  update snapshots
  rename spec files
  rename files
  update snapshots
  release 9.5.4 [skip ci]
  fix(regression): cy.pause() should not be ignored with `cypress run --headed --no-exit` (#20877)
  fix: add missing Cypress.Commands.addAll() types (#20894)
  chore: Don't store video and screenshot artifacts for runs (#20979)
  chore: Update Chrome (beta) to 101.0.4951.26 (#20957)
  chore: remove parallelism from test-binary-against-repo jobs (#21004)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pause() should not be ignored with cypress run --headed --no-exit
4 participants