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

Reject the underlying promise in the Module API when Cypress fails to run the tests #4036

Closed
brian-mann opened this issue Apr 25, 2019 · 3 comments
Assignees
Labels
cli existing workaround type: enhancement Requested enhancement of existing feature

Comments

@brian-mann
Copy link
Member

brian-mann commented Apr 25, 2019

Currently if Cypress errors out and does not run the test (which can happen due to misconfiguration, wrong arguments, failing to record, etc) it does not preserve the error - nor does it make it accessible via the module API.

Currently when using the module API and an error occurs, we have fallback code in the CLI here: https://github.com/cypress-io/cypress/blob/master/cli%2Flib%2Fcypress.js#L31 which resolves with a pretty useless object.

Instead, we should actually reject the underlying promise and rehydrate the error instance that caused Cypress to abandon running the tests.

Here's an issue for reference: #4021

@brian-mann brian-mann added the type: enhancement Requested enhancement of existing feature label Apr 25, 2019
@brian-mann brian-mann self-assigned this Apr 25, 2019
@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Apr 26, 2019
@jennifer-shehane
Copy link
Member

Wanted to add the example of what a workaround for this looks like today.

Some idea of kind of how the code may look as originally posted by @brian-mann here: #4021 (comment)

const cypress = require('cypress')

const didRunError = (results) => {
  return results.message && results.message.includes('Could not find Cypress test run results')
}

// run using our module API
cypress.run()
.then((results = {}) => {
  if (didRunError(results)) {
    // do your fallback behavior here
  }
})

@Nomeasmo
Copy link

I think the above workaround does not

Instead, we should actually reject the underlying promise and rehydrate the error instance that caused Cypress to abandon running the tests.

@jennifer-shehane
Copy link
Member

The Module API does now have an error accessible when it fails to run. See https://on.cypress.io/module-api#Handling-errors

@jennifer-shehane jennifer-shehane removed the stage: ready for work The issue is reproducible and in scope label Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli existing workaround type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

3 participants