How to use two stepdefinitions.ts files in different folder locations in a cypress project?

1k Views Asked by At
"main": "index.js",
 "cypress-cucumber-preprocessor": {
 "step_definitions": "src/shared/support/step_definitions/"
 }
}

This is how it is written in the package.json. Is there any way I add another .ts file of another location, so that when a feature file is running, it will check both stepdefinitions files for automated implementation?

Edit: I also need to know whether there is any other preprocessor that allows me to include & specify stepdefinitions file in two different folder locations.

That is,

Instead of src/shared/support/step_definitions/ I need to specify two locations where cypress can look for step definitions while running the tests. Is there any preprocessors available which allows it?

2

There are 2 best solutions below

3
On

If you look at the documentation here: https://github.com/TheBrainFamily/cypress-cucumber-preprocessor#cypress-configuration, I think you want to add '"nonGlobalStepDefinitions": false' to your package.json. That looks like it'll treat all step definitions as global.

2
On

So if you want to have src/shared/support/folder_a_step_definitions_

and src/shared/support/folder_b_step_definitions/

why don't you do src/shared/support/step_definitions/folder_a src/shared/support/step_definitions/folder_a

and setup the preprocessor to look for the step_definitions recursively here -

src/shared/support/step_definitions/