Dhamo
Dhamo

Reputation: 1251

Error: Step implementation missing for: [step_definition] with cypress & Cucumber when using Scenario outline with example

I have the following Cucumber BDD set up based on Cypress.io. The test runs fine when hard coding the value but failing when it is given in the "Scenario Outline with example' way. What am I missing?

Error:

enter image description here

Feature file:

enter image description here

Step Def:

enter image description here

Version:

Cypress 7.1.0: cypress-cucumber-preprocessor: "^4.0.3",

Upvotes: 1

Views: 4079

Answers (3)

Guillaume de Toulouse
Guillaume de Toulouse

Reputation: 21

As always, the explanation is in the documentation.

If you use Cucumber expression {string}, then the string to be matched MUST be enclosed in quotes (double ou single).

Your given line in feature file should be like:

When keying the vessel identifier 'something' on the search box

https://cucumber.io/docs/cucumber/cucumber-expressions/ (Parameter types)

{string} : Matches single-quoted or double-quoted strings, for example "banana split" or 'banana split' (but not banana split). Only the text between the quotes will be extracted. The quotes themselves are discarded. Empty pairs of quotes are valid and will be matched and passed to step code as empty strings.

Upvotes: 2

Dhamo
Dhamo

Reputation: 1251

After trying all combinations, this (using regex) one worked.

When(/^keying the vessel identifier ([^"]*) on the search box$/, searchTerm => {
    Search.doSearch(searchTerm)
});

Upvotes: 0

TestK
TestK

Reputation: 333

You are passing it {String}, but instead it should be {string}, all lowercase. That should fix your issue.

When(/^keying the vessel identifier {string} on the search box$/, (vesselName) => {
    Search.doSearch(searchTerm)
});

Edit:

Please try this instead, removing the regex pattern and instead using double quotes to define your WHEN statement. If you are using a regex pattern, then I do not believe you are able to use {string} to define a string parameter in your step.

When("keying the vessel identifier {string} on the search box", (vesselName) => {
    Search.doSearch(searchTerm)
});

Upvotes: 1

Related Questions