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

Generated step definition snippets are not found #732

Closed
temyers opened this issue Jan 20, 2017 · 5 comments
Closed

Generated step definition snippets are not found #732

temyers opened this issue Jan 20, 2017 · 5 comments

Comments

@temyers
Copy link
Contributor

temyers commented Jan 20, 2017

I'm running 2.0.0-rc.6

Given a feature file:

Scenario: In range shout is heard
    Given Lucy is at [0, 0]
    And Sean is at [0, 900]
    When Sean shouts
    Then Lucy should hear Sean

When I run cucumberjs, it outputs the following snippet:

Step: Given Lucy is at [0, 0] - features/hear_shout.feature:6
   Message:
     Undefined. Implement with the following snippet:

       Given('Lucy is at [{arg1:int}, {arg2:int}]', function (arg1, arg2, callback) {
         // Write code here that turns the phrase above into concrete actions
         callback(null, 'pending');
       });

When I add the snippet in a step definitions file, the method is not called/found. The same output above is produced.

But, re-writing the step definition to use regular expression:

Given(/^Lucy is at \[(\d+), (\d+)\]$/, function (x, y, callback) {
    callback(null, 'pending');
  });

Then step is found, and marked as pending (expected output)

Step: Given Lucy is at [0, 0] - features/hear_shout.feature:6
   Step Definition: features/step_definitions/shout_steps.js:10
   Message:
     Pending
@charlierudolph
Copy link
Member

Thanks for the issue. My guess would be the brackets are not being escaped when the string is converted to a regex

@temyers
Copy link
Contributor Author

temyers commented Jan 20, 2017

Thanks. I'll try and investigate.

@charlierudolph Can I default the snippet style to regex?

@charlierudolph
Copy link
Member

@temyers the brackets not being escaped unfortunately is a an issue with one of cucumber-js dependencies (see the linked issue). For now, there is no way to switch back to regex for snippets. I don't think that would be too hard to build however.

@aslakhellesoy any objection to adding in a switch to allow the snippet pattern format to be regex instead of cucumber expressions? The default will still be cucumber expressions

@charlierudolph charlierudolph added 🐛 bug Defect / Bug 🙏 help wanted Help wanted - not prioritized by core team bug in dependency and removed 🙏 help wanted Help wanted - not prioritized by core team 🐛 bug Defect / Bug labels Jan 28, 2017
@charlierudolph
Copy link
Member

This was fixed with the upgrade to [email protected]. I'm going to break out the ability to change the default snippet style into its own story.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants