I’m working with Cypress and decided to install Cucumber, ive created a feature file which successfully runs the step definitions in the Cypress runner but my cucumber steps are still being highlighted as Undefined in VS Code
Ive tried lots of different configs for the cypress.config.js file but cant get anything to work
There is a similar post in Stackoverflow but that solution wouldnt work for me as i dont use Intellij or TypeScript
Any help appreciated
Here are my dependencies:
"@badeball/cypress-cucumber-preprocessor": "^21.0.2",
"@cypress/webpack-preprocessor": "^6.0.2",
"@testing-library/cypress": "^10.0.2",
"cypress": "^13.15.0",
"globals": "^15.11.0",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.3"
Here is my cypress.config.js file
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const cucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
const esbuildPreprocessor = require("@badeball/cypress-cucumber-preprocessor/esbuild");
module.exports = {
e2e: {
specPattern: [
'cypress/e2e/**/*.feature', // Define path to feature files
'cypress/e2e/0-test/*.js', // Define path for regular specs
// 'cypress/e2e/support/step_definitions/**/*.js', // Define the glue path
],
// stepDefinitions: 'cypress/e2e/support/step_definitions/**/*.js', // Explicitly set the path for step definitions
async setupNodeEvents(on, config) {
await cucumberPreprocessor.addCucumberPreprocessorPlugin(on, config);
on(
"file:preprocessor",
createBundler({
plugins: [esbuildPreprocessor.createEsbuildPlugin(config)],
})
);
return config;
},
},
};
Here is my feature file
Feature: Example Feature
Scenario: Example Scenario
Given I visit the home page
Then I should see the welcome message
Here are my step definitions
const { Given, Then } = require("@badeball/cypress-cucumber-preprocessor");
Given("I visit the home page", () => {
debugger;
cy.visit("https://example.com");
});
Then("I should see the welcome message", () => {
cy.contains("Example Domain");
});
My folder structure
