jest-cucumber icon indicating copy to clipboard operation
jest-cucumber copied to clipboard

Global steps

Open AaronBuxbaum opened this issue 5 years ago • 2 comments

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

AaronBuxbaum avatar Sep 24 '19 14:09 AaronBuxbaum

Is there an ETA on this being merged? I am really keen to use this functionality.

Philyorkshire avatar Oct 04 '19 15:10 Philyorkshire

I've made background steps work here: https://github.com/ian7/jest-cucumber/tree/background

ian7 avatar Jan 30 '20 15:01 ian7