Is there a way to stop test execution when one test fails?
What are you trying to achieve?
So, one of the test scenario fails due to 503(Service Unavailable error) error. But, other scenarios in the test file continue to run. Is there a way to stop the execution when any of the test step fails??
What do you get instead?
Tests continue to run on failure.
It would be great if we can stop the test execution on failure in order to debug and also prevent other tests from failing.
You could create your own hook https://codecept.io/hooks#event-listeners and on event.test.failed(test, error) manually kill the node process.
@DevinWatson Thanks for the update. Currently, we use the above mentioned hook in order to have a better understanding on test failure. Our tests run in BrowserStack on scheduled time intervals, killing the node manually isn't possible. So, wanted to check is there any other alternative to stop tests.
maybe you can do nodejs functionality..
Codecept runs on top of Mocha test framework. Mocha has the bail option to stop testing after the first failure. https://mochajs.org/api/mocha
You just need to pass the bail option to Mocha via the codecept config file:
{
tests: './*_test.js',
timeout: 10000,
output: '',
helpers: {},
mocha: { bail: true }
}
@xt1 do you think it is possible to bail after specific test case only? For example, if logging to application fails
Thanks @xt1. Will try the bail option.