Is it possible to navigate from feature file to step definition in VSCode

Vignesh Paramasivam picture Vignesh Paramasivam · Jul 19, 2017 · Viewed 12.7k times · Source

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?

Answer

Daniel Fintinariu picture Daniel Fintinariu · Jul 24, 2017

You can install Cucumber Full Language 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!