Closed lolmaus closed 2 years ago
Hi @lolmaus,
I'm struggling to reproduce. You can find the code that substitutes placeholders with values here. It builds the example placeholder name into a regular expression, e.g. \[\s*Element\s*\]/g
and will replace all matches with the example value retrieved from the example table. If the regular expression doesn't match, then the placeholder shouldn't be substituted.
Can you post your full feature/scenario please so I can debug further.
You can't, but you can use specify custom placeholder delimiters via the leftPlaceholderChar
and rightPlaceholderChar
options. If you're using either the FeatureParser or FeatureFileParser directly, you can do one of the following
const featureParser = new FeatureParser({ leftPlaceholderChar: '<', rightPlaceholderChar: '>' });
const featureFileParser = new FeatureFileParser({ leftPlaceholderChar: '<', rightPlaceholderChar: '>' });
However if you're using the mocha plugin, these options will sadly be dropped. Instead you'll need to instantiate the parser manually, and pass it to the plugin when you call init.
const parser = new FeatureFileParser({ leftPlaceholderChar: '<', rightPlaceholderChar: '>' });
Yadda.plugins.mocha.StepLevelPlugin.init({ parser });
I made a minor change to simplify customisation with the mocha plugin. As of 2.2.0 the options are passed straight through from the plugin to the FeatureParser so you can simply do
Yadda.plugins.mocha.StepLevelPlugin.init({ leftPlaceholderChar: '<', rightPlaceholderChar: '>' });
Any update @lolmaus?
Hi!
I have this step in the
Backround
section and it works as expected:When I add an examples table to one of scenarios, the above step crashes with the following error:
Apparently, the empty array literal has been treated as an examples table placeholder and replaced with an empty string.
Questions:
How do I escape an examples table placesholder, so that I can use literal
[]
or[Matching Placeholder]
in a step? Something likeCC @simonihmig