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

Cypress.automation is rejected but does not show an error #8547

Closed
bahmutov opened this issue Sep 10, 2020 · 3 comments
Closed

Cypress.automation is rejected but does not show an error #8547

bahmutov opened this issue Sep 10, 2020 · 3 comments
Assignees
Labels
type: unexpected behavior User expected result, but got another

Comments

@bahmutov
Copy link
Contributor

Cypress v5.1.0 with Electron browser on Mac

beforeEach(() => {
  // allow downloads in Electron
  Cypress.automation('remote:debugger:protocol',
    { command: 'Page.setDownloadBehavior',
      params: { behavior: 'allow' } })
})

for cypress-io/cypress-example-recipes#560

blocked

silently fails and only the DevTools shows an error later in the console

Screen Shot 2020-09-10 at 2 16 18 PM

Proposal

If Cypress.automation rejects, fail the test and show the error

@bahmutov bahmutov added the type: unexpected behavior User expected result, but got another label Sep 10, 2020
@brian-mann
Copy link
Member

this is not a command - its just a regular promise and it needs to be returned, and then it'll fail the test. all regular promises work this way.

@brian-mann
Copy link
Member

there's a separate issue i opened not too long ago suggesting we tap into the unhandledrejection global event and then possibly fail the test: #8236

it goes way back to another issue i opened years ago: #243

@bahmutov
Copy link
Contributor Author

Workaround

beforeEach(() => {
  // The next command allow downloads in Electron, Chrome, and Edge
  // without any users popups or file save dialogs.
  if (Cypress.browser.name !== 'firefox') {
    // since this call returns a promise, must tell Cypress to wait
    // for it to be resolved
    cy.wrap(
      Cypress.automation('remote:debugger:protocol',
        {
          command: 'Page.setDownloadBehavior',
          params: { behavior: 'allow', downloadPath: downloadsFolder },
        }),
      { log: false }
    )
  }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

3 participants