Skip to content
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

'skipped' status returned from When is not preventing the execution of Then step #1312

Closed
sfdcale opened this issue Apr 24, 2020 · 6 comments
Labels
🤔 cannot reproduce Claimed bug cannot be reproduced

Comments

@sfdcale
Copy link

sfdcale commented Apr 24, 2020

I am struggling to skip the execution of Then step when status returned from When method is 'skipped':

Snippet1:
This is not working(Then step is executed)

this.When(/^Status returned is Skipped$/, {retry: 2}, () => {
    let output = resultOfSomeOperation();
    if(output > 0){
        return 'skipped';
    }
});

Snippet2:
This is working(Then step is not executed)

this.When(/^Status returned is Skipped$/, {retry: 2}, () => {
    let output = resultOfSomeOperation();
    if(output > 0){
        return 'pending';
    }
});

Why snippet1 is not skipping the execution of Then step?

My ultimate goal is to skip the execution of Then step based on the results of some operation in When step.

@charlierudolph
Copy link
Member

Auhh. The original requirements for the "skipped" feature involved being able to skip a scenario from a before hook. This seems like a valid use case and something that needs to be fixed.

@tibawatanabe
Copy link

Hum... so is the example from skipped_steps.feature not valid/not something we should use as reference? Considering its content I'd assume that a skipped Given would work regardless of a hook.

@aslakhellesoy aslakhellesoy added the ⚡ enhancement Request for new functionality label Feb 2, 2021
@davidjgoss davidjgoss added ✅ accepted The core team has agreed that it is a good idea to fix this good first issue Good for newcomers labels Jul 14, 2021
@davidjgoss
Copy link
Contributor

This feature describes and tests the current behaviour around "skipped" https://github.com/cucumber/cucumber-js/blob/main/features/skipped_steps.feature - we'd be adding a couple more scenarios there to cover skipping from steps.

The status is being set on the basis of the "skipped" result from the step code here https://github.com/cucumber/cucumber-js/blob/main/src/runtime/step_runner.ts#L66 - so the orchestration a level up in https://github.com/cucumber/cucumber-js/blob/main/src/runtime/test_case_runner.ts is probably where we need to make changes.

gloryCU added a commit to gloryCU/cucumber-js that referenced this issue Jan 19, 2022
We're confused because we expected the scenario to fail but it is
passing.

Co-authored-by: Matt Wynne <matt@mattwynne.net>
@gloryCU
Copy link

gloryCU commented Jan 19, 2022

@mattwynne and I tried to reproduce the scenario but surprisingly, it doesn't fail. Here's a link: main...RukenaG:fix-#1312?

@sfdcale, do you see anything wrong with our implementation of the scenario?

@davidjgoss is it possible this bug has been fixed accidentally since this bug was reported?

@davidjgoss
Copy link
Contributor

@RukenaG so sorry for the late reply! The scenario you added looks great. Would you be okay to raise a pull request? We'll probably need to update some docs at the same time.

Yeah looking now, it's very possible this happened by accident, probably as part of the big rework to use the messages protocol.

@davidjgoss davidjgoss added 🤔 cannot reproduce Claimed bug cannot be reproduced and removed good first issue Good for newcomers ✅ accepted The core team has agreed that it is a good idea to fix this ⚡ enhancement Request for new functionality labels May 30, 2022
@davidjgoss
Copy link
Contributor

Closing this as per discussion the current behaviour includes skipping at the step level.

@gloryCU would still be happy to take a PR for that scenario, as that's valuable coverage and documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 cannot reproduce Claimed bug cannot be reproduced
Projects
None yet
Development

No branches or pull requests

6 participants