Search code examples
javascriptcucumbercypressbddcypress-cucumber-preprocessor

How to access feature files in cucumber using Cypress latest version (10.2.20)


I have been working on Cypress's latest version (10.2.0) with BDD in cucumber. Everything's working fine just my feature files are not accessible. I have tried using SpecPattern as written in the documentation but no help.

The spec pattern line is as follows:

    specPattern: "/cypress/e2e/**/*.feature"

Also, My cucumber is imported and running fine

Cypress.config file:

const { defineConfig } = require("cypress");
const cucumber = require('cypress-cucumber-preprocessor').default

module.exports = defineConfig({
e2e: {
  setupNodeEvents(on, config) {
    on('file:preprocessor',cucumber())
    // implement node event listeners here
  },

Package.Json File:

"devDependencies": {
    "cypress-cucumber-preprocessor": "^4.3.1"
  },
  "cypress-cucumber-preprocessor":{
    "nonGlobalStepDefinitions" : false
  }
}

Image showing there is no feature file in this directory

While my feature file is present in the same directory shown in the above picture

Any help would be appreciated


Solution

  • You should change your cypress-cucumber library.

    This indicates you have an old version

    const cucumber = require('cypress-cucumber-preprocessor').default
    

    You should use this version

    // package.json
    
    "@badeball/cypress-cucumber-preprocessor": "^11.3.0",
    
    // cypress.config.js
    
    const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
    

    Repo, instructions etc Github