jest-cucumber
jest-cucumber copied to clipboard
Support Cucumber Expressions
trafficstars
https://cucumber.io/docs/cucumber/cucumber-expressions/
"User enters {string} name" is much nicer than /^User enters (.*) name$/.
Agreed, this would be great to support.
I need that feature on my current project, I gave a try on this feature
I've concerned several approaches
- use cucumber-expression lib
- string preprocessing to detect if it contains {int} {string} etc. and then evaluate to RegExp
- add CucumberExpression as a type of step matcher
Currently I've done POC using second approach - string preprocessing, replace {int} {string} with corresponding regex,
'{int}': '\\$(\\d+)',
'{double}': '^(-?)(0|([1-9][0-9]*))(\\.[0-9]+)?$',
'{string}': '"(.*)"', // example
It might seem quite hacky but works for me.
