Search code examples
cucumbercypress

Where to put step defs in cyrpess, cucumber project - "Cant walk dependency graph"


I just updated my project from Cypress 9.x.x to cypress 10 and managed to get the tests running, but only if the example.feature file and step definition file (example.ts) are under e2e folder.

Example:

e2e
  example.feature
  example.ts

If I change the structure, for example moving the step defintion to their own folder the tests fail and I get Can't walk dependency graph: What I would like to do is to put the step definition files and feature files in their own folder.

Example:

e2e
  features
      example.feature
      example2.feature
  step definitions
      example.ts
      example2.ts

I've been trying to change the specPattern in cypress.config.ts or is it package.json that needs to be changed? I'm not sure where to do the change or if this is a good way/ best practice of the file setup in cypress 10.


Solution

  • If you are using the latest version of cypress-cucumber that is @badeball/cypress-cucumber-preprocessor, then in your package.json, you have to add the path to your step definition files like this:

    "cypress-cucumber-preprocessor": {
      "stepDefinitions": "cypress/e2e/step definitions/**/*.{js,ts}"
    }