Search code examples
rubycucumbervisual-studio-codegherkin

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


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?


Solution

  • 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!