-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Option to "fail fast" on BeforeFeatures catastrophic failure #792
Comments
The |
I examined this behavior, and I now understand that my problem actually stems from Thanks for the prompt reply. |
Upon further investigation it seems the when the beforeFeatures hook fails, the CLI exists, but with exit code = 0 (I expected it to be 1) |
We have tests that the build fails when a handler errors. What version are you using and can you please provide the minimal code for a reproducible example? |
Cucumber 1.2.1 I've managed to narrow down the problem to the following single change. BeforeFeatures hook throws an error:module.exports = function () {
this.registerHandler('BeforeFeatures', function(){
throw new Error('Something bad');
});
};
BeforeFeatures hook returns a rejected promisemodule.exports = function () {
this.registerHandler('BeforeFeatures', function(){
return Promise.reject(new Error('Something bad'));
});
}; OR module.exports = function () {
this.registerHandler('BeforeFeatures', function(){
return Promise.resolve().then(() => {
throw new Error('Something bad');
});
});
};
|
Hmmm. Actually now that I know what it stems from, it seems to be covered in #708, which was resolved in 2.0. Is that the case? |
Uncertain. That issue mentions that it works as expected in 1.3.1. That issue got raised due to a change in how the code in built in 2.0. Thus that issue was 2.0 specific. |
Seems to be caused by throwing the error synchronically in Just to test things, I changed I don't presume to know enough about cucumber's internals and error propagation to say this should be the solution (it seems arbitrary, and for all I know might break everything). Just sharing my findings hoping that it would lead to the real solution. |
Any chance you could open a PR with your changes? It would be against the "1.x" branch. The PR will run all the tests and we can see its effect. |
Sure. |
I would add that there is always the possibility to |
Sorry for the confusion with the first PR. The solution I committed is less radical than the changes I specified here. I simply throw the error within process.nextTick so it won't be in the promise context. This solution has no consequences on the calling code. |
@yaronassa Just released |
@charlierudolph |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
While I don't want to use the --fail-fast behaviour (i.e., I want all the tests that could run, to run, regardless of previous failures), I do want to "fail fast" if the BeforeFeatures hook fails (since that means something very fundamental in my env. setup has failed).
A quick and dirty way to achieve a similar practical result could be for BeforeFeatures to be able to flip the --fail-fast switch, so that the first step run will be the last. A better solution would be for a promise rejection from that hook to immediately fail the run, regardless of the fail fast flag.
What do you think?
The text was updated successfully, but these errors were encountered: