amiceli / vitest-cucumber

Use gherkin in your unit tests with vitest
https://vitest-cucumber.miceli.click
41 stars 5 forks source link

Suggestion: Alternatives expressions #147

Open Odonno opened 1 month ago

Odonno commented 1 month ago

Following the #144 proposition, discussed here the feasibility and the need for Alternative expressions feature.

Description

A less common feature is the ability to offer alternatives in the step text.

I have {int} cucumber(s) in my belly/stomach

This would match either of those texts:

I have 1 cucumber in my belly
I have 1 cucumber in my stomach
I have 42 cucumbers in my stomach
I have 42 cucumbers in my belly

References

https://github.com/cucumber/cucumber-expressions?tab=readme-ov-file#optional-text https://docs.specflow.org/projects/specflow/en/latest/Bindings/Cucumber-Expressions.html#optionals-alternatives

amiceli commented 3 weeks ago

I reed some docs but I don't find a use case to understand this feature. It's usable only with expression like {int} ?

Or a step like Given Developper on public/private projects is a good example ?

Odonno commented 3 weeks ago

Yep, your last example could work. But in general, it is for when you want to use a synonym. In your example, it is an antonym, I suppose it can work in some contexts.

I do not have a great example as I do not use this feature. Like I said, if someome needs this feature, he can share a viable example so we can work on that.