Skip to content

Module API doesn't fail the promise with Cypress failure messages #3216

Closed as not planned
@NicholasBoll

Description

@NicholasBoll

Forgive me if this issue exists, I wasn't able to find it.

Current behavior:

If using the Module API and Cypress fails for various reasons (baseUrl isn't reachable, spec isn't found) the module API resolves with a shape of { failures: 1, message: "Cypress error message" } instead of rejecting.

Desired behavior:

The module API should reject the promise with an error message. This is then easier to detect failure cases. There is a difference between failing to run because of some error and running successfully and returning results that could contain failed tests.

Steps to reproduce: (app code and test code)

You can run this from from any project that has Cypress in it:

node -e "\
  var cypress = require('cypress');\
  cypress.run({ spec: 'does-not-exist.js' })\
  .then(result => {\
    console.log('result', result);\
    process.exit(0);\
  })\
  .catch(error => {\
    console.log('error', error); /* we never get here */\
    process.exit(1);\
  })"

Running that will output a red error message from Cypress, but the process will exit with a 0. Even without an explicit process.exit and having no .catch will do the same thing. The issue can be mitigated by adding the following after the .then(result => line:

if (result.failures) {
  throw result
}

Versions

Cypress 3.1.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage: proposal 💡No work has been done of this issuestaleno activity on this issue for a long period

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions