Reputation: 309
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
In tried a lot of things, but I didn't manage to solve this issue. Any suggestions?
Upvotes: 14
Views: 37399
Reputation: 21
In my case it was a long road. First off all we are using YARN so you have to add pluginsFile, npm_dependencies to browserstack.json
"run_settings": {
"cypress_config_file": "./cypress.json",
"pluginsFile": "cypress/plugins/index.js",
"cypress_version": "7",
"project_name": "My sandbox project",
"build_name": "Build no. 1",
"parallels": "5",
"npm_dependencies": {
"cypress": "^9.0.0",
"cypress-cucumber-preprocessor": "^4.3.0"
}
}
Second element it's 1
create the file .cypress-cucumber-preprocessorrc.json project directory
{ "nonGlobalStepDefinitions": true, "cucumberJson": { "generate": "true", "outputFolder": "cypress/cucumber-json", "filePrefix": "", "fileSuffix": ".cucumber" } }
Thanks a lot @Vinayak Shedgeri
Upvotes: 0
Reputation: 76
This worked for me.
Upvotes: 2
Reputation: 241
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
stepdefinations/ .js
file should always be in a folder which we have created earlier).Upvotes: 23
Reputation: 2392
create the file .cypress-cucumber-preprocessorrc.json project directory
{
"nonGlobalStepDefinitions": true,
"cucumberJson": {
"generate": "true",
"outputFolder": "cypress/cucumber-json",
"filePrefix": "",
"fileSuffix": ".cucumber"
}
}
Upvotes: 2
Reputation: 21129
Add this in the package.json
with your custom path
"cypress-cucumber-preprocessor": {
"step_definitions": "cypress/integration/features/step_definitions/**/"
}
Upvotes: 3
Reputation: 559
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");
})
Upvotes: 5