cypress-cucumber-preprocessor: Webstorm doesn't recognize step definitions

I don’t really know if I should ask this here, but Webstorm doesn’t recoginize the step definitions of this plugin because the steps are given, when, then. Webstorm does recognize the official cucumber package’s Given, When an Then (capitalized). Webstorm recognizing step definitions is extremely helpful in preventing duplicate step definitions.

// Recognized (like the official cucumber package)
Given(`I am on the webpage`, () => {
  cy.visit(url);
});

// Not recognized (like this plugin)
given('I am on the webpage', () => {
  cy.visit(url);
});

webstormnotrecognizingcypresscucumber

I did find a workaround, but I’d rather not have people forget to include this:

// Just add this above the step definitions
const Given = given;
const When = when;
const Then = then;

Is there a way this could be solved without a workaround?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 23 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@lgandecki

I will change my PR and check if the build works when I do the const Given = given stuff.

@vadimromanyak You can also use ticks:

Given(`user navigated to the Start page`, () => {});

If you check out the test steps I created (webstormSupport.steps.js) you can see I use either the ticks or /^…?/:

When(/^I write my steps using caps$/, () => {
  counter += 1;
});

By the way, we can’t really test Webstorm support itself I guess, only that the capitalized version is working correctly within the plugin.

https://youtrack.jetbrains.com/issue/WEB-32819 for follow-up. You can “thumb-up” to make it gain interest, and/or watch the issues for updates.

@kayvanbree well, yeah, the /^ gives you the regexp functionality… but the point is, instead of using regexp, you can just use the newer syntax…

to give you an example, instead of:

then(/(.*?) is chosen/, choice => {})
then(/my lucky number is (\d+)/, number => {})
then(`{word} is chosen`, choice => {})
then(`my lucky number is {int}`, number => {})

Regexps are powerful, but unreadable to human, and very rarely u need such a complex processing anyway, usually it’s a word, or a number, etc… so the cucumber guys introduced the new syntax 😃

@vadimromanyak replacing with /^ etc is not preferable as then we lose the prefered / new / cleaner syntax:

https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md

But I’m excited that the backticks work, not sure why webstorm wouldn’t work with " or ’ but hey, not a huge deal once you know it 😃

@lgandecki Webstorm doesn’t recognize step definition this way:

Given('user navigated to the Start page', () => { });

But if we replace quotes with /^…?/ then it works:

Given(/^user navigated to the Start page?/, () => { });