I'm trying to convert my RegExp based Cucumber v1 step definitions into Cucumber Expression based Cucumber v2.0.0-rc.9 step definitions. I have a few step definitions that use regular expressions like the following:
/^I (?:am on|go to) the "([^"]*)" page$/
That way, I can write either of the following in my feature file:
I am on the "Login" page
I go to the "Home" page
I'd like to switch to Cucumber Expressions so that I can start making use of Custom Parameters, but I can't find a great way to duplicate the (?:am on|go to)
. The best I've come up with is to use multiple alternative texts:
I am/go on/to the "{captureString}" page
What I don't like about that approach though is that it allows for writing nonsensical steps like the following:
I am to the "Login" page
I also tried using a single optional text that contained a |
character like so:
I (am on|go to) the "{captureString}" page
but cucumber-expressions-javascript intentionally escapes the |
character, so the resulting RegExp looked like this:
/^I (?:am on\|go to)? the "([^"]*)" page$/
Is there any way to have a single, multi-word alternative text group using Cucumber Expressions?