Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gherkin: Scenario Outline variable subsitution not working for variables that contain special regex characters #1042

Closed
ghost opened this issue Jun 9, 2020 · 0 comments · Fixed by #1077
Labels
🐛 bug Defect / Bug language: javascript library: gherkin 🧷 pinned Tells Stalebot not to close this issue

Comments

@ghost
Copy link

ghost commented Jun 9, 2020

It was suggested to me in cucumber/cucumber-js#1322 that I create an issue here instead.

Summary

We often use phrases like "is triggered" and "is not triggered". In scenario outlines. We phrase it as "the thing <is (not) triggered>". But when running the tests with cucumber-js, the step is not found because the variable is not replaced properly due to its parenthesis. I did not test any further but I reckon that all special regex characters will produce this problem.

Here an example:

  Scenario Outline: Parenthesis
    Given the thing <is (not) triggered> and has <value>

    Examples: Thing
      | is (not) triggered | value |
      | is triggered       | foo   |
      | is not triggered   | bar   |
      | is triggered       | baz   |

Expected Behavior

The variable should be replaced properly. It works in the python behave package.

Current Behavior

The variable does not get replaced.

Possible Solution

In the other issue we found out that https://github.com/cucumber/cucumber/blob/master/gherkin/javascript/src/pickles/compile.ts#L218 is probably the culprit. The variable name is used directly inside the search RegEx, but it should be be escaped before. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping

Your Environment

Versions:
Ubuntu 18.04.4 LTS
cucumber-js: 6.0.5
node: v10.20.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug language: javascript library: gherkin 🧷 pinned Tells Stalebot not to close this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant