We have a large test suite running on a CI server, and there appears to be no way of telling Cypress to exit if a test fails. It always runs the entire suite.
There is some discussion here, but no workable solution.
Is there a reliable way to have Cypress exit as soon as a test fails?
Cypress gives us the ability to stop the test at a spot via cy. pause() command. We can use this to stop the test before any action or assertion that is causing our tests to fail.
You can configure this in the Cypress configuration by passing the retries option an object with the following options: runMode allows you to define the number of test retries when running cypress run. openMode allows you to define the number of test retries when running cypress open.
The retry-ability allows the tests to complete each command as soon as the assertion passes, without hard-coding waits. If your application takes a few milliseconds or even seconds to render each DOM element - no big deal, the test does not have to change at all.
You can also use this Cypress plugin meanwhile Cypress does not support this feature natively: https://www.npmjs.com/package/cypress-fail-fast
Add the plugin to devDependencies:
npm i --save-dev cypress-fail-fast
Inside cypress/plugins/index.js:
module.exports = (on, config) => {
require("cypress-fail-fast/plugin")(on, config);
return config;
};
At the top of cypress/support/index.js:
import "cypress-fail-fast";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With