jest-cucumber
jest-cucumber copied to clipboard
Global steps
Implements a function which allows the user to define global steps.
The system searches for a global match if there is no step defined (ie. when('I click the button')
as opposed to when('I click the button', () => {...})
). When this happens, we search through the available global steps; if no match exists, it will throw an error.
In addition, code generation should search through the global steps and automatically remove the function callback where there is an existing global step with the same name.
Lastly, I added an opt-in option to disable code generation from giving you regexes -- this is because the regex match for globals is quite precarious (it needs to be a === string match), and because with global steps, you may actually want all of your steps to be strings and to throw on any change. You probably won't need it for most cases, but it's good to have.
Thanks to @pedrowilkens for the idea -- this is effectively his code with a few adjustments: https://github.com/bencompton/jest-cucumber/issues/52#issuecomment-466770413
Is there an ETA on this being merged? I am really keen to use this functionality.
I've made background steps work here: https://github.com/ian7/jest-cucumber/tree/background