Description
🤔 What's the problem you're trying to solve?
It appears that the only way to have a literal /
within a step requires the use of a regex, to avoid the step being interpreted as an alternation. For example, if I wanted to have:
When I do an A/B test
...I might intuitively write the following steps:
When "I do an A/B test"
However, this gets interpreted as alternation, so we end up with the equivalent
When /^I do an (A|B) test$/
Seemingly a \
does not do anything here, so I have to fall back to a regex match:
When /^I do an A\/B test$/`
...which just makes things look more complicated than they really are.
✨ What's your proposed solution?
Escaping the /
feels like the best choice, although it does result in very ugly steps:
When 'I do an A\/B test'
An alternative could be to re-use /
as the escape here, for example:
When "I do an A//B test"`
...or for languages which support annotation / keyword-arguments, the ability to simply disable expression parsing:
When "I do an A/B test", as_expression: false
⛏ Have you considered any alternatives or workarounds?
Falling back to regexp is a simple enough workaround, and hoisting the /
-containing term to a ParameterType
also fixes the problem. However, given that there are escapes for {}
and ()
, it feels natural that /
should too.
📚 Any additional context?
cucumber (8.0.0)
cucumber-core (11.0.0)
cucumber-cucumber-expressions (15.2.0)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status