Description
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