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

Feature: AND support #220

Closed
J7mbo opened this issue Sep 13, 2024 · 2 comments
Closed

Feature: AND support #220

J7mbo opened this issue Sep 13, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@J7mbo
Copy link

J7mbo commented Sep 13, 2024

The problem
It would be very useful to have AND support in features instead of using multiple Givens or Whens:

Given one thing
And another thing

instead of:

Given one thing
Given another thing

cucumber reference

@J7mbo J7mbo added the enhancement New feature or request label Sep 13, 2024
@J7mbo
Copy link
Author

J7mbo commented Sep 13, 2024

I just saw that we CAN use AND in the feature file itself. It's just that in the step file we have to use the Step function. Although it would be nice to have an And() call instead of a Step call just to reduce the cognitive overhead due to the difference, I'm closing as it's unlikely to make it in.

@J7mbo J7mbo closed this as completed Sep 13, 2024
@vitalets
Copy link
Owner

vitalets commented Sep 16, 2024

Hi @J7mbo
Yes, you can use AND in feature files and it is not required to define such steps with Step function. You can use any of Given, When, Then. I will highlight it in docs, that Cucumber treats all these functions as aliases and matches step only by pattern, not by keyword. Here are a few issues with some explanation:

So thanks for raising that!

Concerning And() function - I think the same step can be often used with both full keyword and AND / BUT, step definition should not know about that context. Such functions were deprecated in Cucumber for Cypress, for the same reason.

While investigating this issue, I found that there were several discussions on enforcing strict keyword matching:

I think it's a good option to let users of playwright-bdd enable such mode in config.
Created a separate ticket for that: #221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants