Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Step implementation missing for: [step_definition] when trying to run a scenario using cucumber with cypress

I tried to do a simple test to try how cucumber works with cypress, but I didn't manage to solve the problem described in the title.

Bellow is my js file:

import {Given, When, Then} from "cypress-cucumber-preprocessor/steps"
 
Given('I am in the demo site',()=>{
 
    cy.visit("https://www.saucedemo.com/index.html");
 
})

here is my feature file:

Feature: Login Feature
 
Scenario: Login Validation
 
Given I am in the Swag Labs login page

Here is a screenshot with the issue enter image description here

In tried a lot of things, but I didn't manage to solve this issue. Any suggestions?

like image 366
Sebastian Avatar asked Jan 22 '20 10:01

Sebastian


4 Answers

Finally, I have identified the solution.The issue is with the folder structure and naming conventions. Below are the two main rules we need to follow

  1. Folder name and Feature file name should be the same
  2. Feature file and step definitions should not be in the same folder ( stepdefinations/ .js file should always be in a folder which we have created earlier).

enter image description here

like image 163
user14905817 Avatar answered Oct 10 '22 15:10

user14905817


Your step definition file should be

import {Given, When, Then} from "cypress-cucumber-preprocessor/steps"

Given('I am in the Swag Labs login page',()=>{

    cy.visit("https://www.saucedemo.com/index.html");

})
like image 45
DavidZ Avatar answered Oct 10 '22 14:10

DavidZ


create the file .cypress-cucumber-preprocessorrc.json project directory

 {
    "nonGlobalStepDefinitions": true,
    "cucumberJson": {
        "generate": "true",
        "outputFolder": "cypress/cucumber-json",
        "filePrefix": "",
        "fileSuffix": ".cucumber"
    }
}
like image 2
Vinayak Shedgeri Avatar answered Oct 10 '22 14:10

Vinayak Shedgeri


Add this in the package.json with your custom path

"cypress-cucumber-preprocessor": {
   "step_definitions": "cypress/integration/features/step_definitions/**/"
}
like image 1
Prashanth Sams Avatar answered Oct 10 '22 13:10

Prashanth Sams