29

I am primarily using RubyMine for Cucumber/Ruby, and now, I'm getting my hands on VSCode, with which I'm able to run and debug test cases.

I can't find a way to navigate from feature to step definition. I tried searching for extensions and cucumber-step-mapper doesn't help.

Is there any config which enables navigation from feature to step definition?

1
  • You can by default with Webstorm. Would love to know if this is possible with Vs Code Commented May 10, 2023 at 20:38

3 Answers 3

54
+50

You can install Cucumber (Gherkin) Full Support extension from the VSCode Marketplace:

After install is finished, reload VSCode. Now in order to make it work for Ruby, you need to:

  • Press Ctrl + , to open User Settings

  • Scroll down to Cucumber Auto Complete

  • On the right side you need to modify these settings (you can find 2 examples of how to do this on the extension page). In my case, I added the following:

     "cucumberautocomplete.steps": [ "features/step_definitions/*.rb" ], "cucumberautocomplete.syncfeatures": "features/*feature" 
  • Reload VSCode

  • Open a .feature file and right click any step, you should have Go To Definition and Peek Definition working.

Hope you get it working!

Sign up to request clarification or add additional context in comments.

10 Comments

Do you see the warning [cucumberautocomplete] was unable to find step for ... while hovering over a step in the feature files? If that is the case, then I think the path must be specified in a different way.
The above did not work for me. I have [cucumberautocomplete] was unable to find step for ... error on every line. I confirmed the folders are correct.
sort of partially works for me - some step definitions correctly navigated to - others not ... :-/
I had some problems with the paths of features and steps. The reason was that I was skipping the creation of a .vscode/ folder mentioned in the extension docs. Just in case this can help someone like it did for me: stackoverflow.com/a/61610271/7012085
i set up my feature files to be inside cypress/integration/, say cypress/integration/google.feature - having that js file would be in cypress/integration/google/google.js and vscode setting for navigation is: "cucumberautocomplete.steps": [ "cypress/integration/**/*.js", ],
|
2

I have a cucumber with java project and following worked for me:

 "cucumberautocomplete.steps": [ "**/*Steps.java" ], "cucumberautocomplete.syncfeatures": "**/*.feature" 

Comments

0

I have cucmber with javascript with cypress and this worked with me {

 "cucumberautocomplete.steps": [ "cypress/e2e/step_definitions/*.js", ], "cucumberautocomplete.syncfeatures": "features/*feature",} 

you should have the right paths from the root of your project path

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.