Skip to content
Advertisement

Multiple Step definition files with Codecept Gherkin

I’m currently working with a Codecept’s Gherkin framework. At the moment my step definition file is huge (1000+ lines) and I want to break it down to smaller, more maintainable chunks but I haven’t been able to find a way of doing with codecept and google hasn’t been much of a help.

In the codecept config file the step definition files are referenced in an array, which leads me to believe that multiple step definition files is possible.

  gherkin: {
features: './features/**/*.feature',
steps: [
        './step_definitions/step_definition_file.js'
      ]
}

I tried adding multiple files with different steps in each but when I run a feature with steps specified in a file that is not first in the array then it doesn’t work(step not specified error).

So how can I specify, in codecept which step definition file a feature is suppose to use?

Advertisement

Answer

For anyone coming across this post this is the solution

In codecept.config file you steps config should look like this

gherkin: {
  features: './features/**/*.feature',
  steps: './step_definitions/**/*.js'
}
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement