Feature file in different directory gives missing step implemantation error with nonGlobalStepBaseDir defined
See original GitHub issueThank you for building this preprocessor and latest update to define nonGlobalStepBaseDir is very helpful.
With the current setup tests are working well. Configurations are set as following with feature files placed in the cypress/integration directory:
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true,
"commonPath":"../../../shared",
"nonGlobalStepBaseDir": "cypress/integration/steps/onboarding/customer"
}
}
I would like to move the feature files to another directory say:
cypress/integration/features/onboarding/customer
Current behavior
Moving the feature files from cypress/integration to another path gives step implementation missing error.
Is it possible move the feature files to another directory with nonGlobalStepBaseDir path defined?
Desired behavior
To be able to define feature file location similar to step definitions.
Test code to reproduce
Versions
- Cypress version: 4.8
- Preprocessor version: 2.5.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Feature file in different directory gives missing step ... - GitHub
Feature file in different directory gives missing step implemantation error with nonGlobalStepBaseDir defined #392.
Read more >Cypress-cucumber - How to store steps in same directory as ...
I have used the basic setup tutorial from cypress-cucumber page. My issue is this. I have a feature file in. integration/feautres/test.feature.
Read more >cypress-cucumber-preprocessor - npm
The cypress-cucumber-preprocessor adds support for using feature files when testing with Cypress. You can follow the documentation below, ...
Read more >E2E Testing with Cypress - 04 - Cucumber / Gherkin Integration
Step Definitions. The steps in the .feature file look for their implementation inside a directory configured from preprocessor configuration.
Read more >Why is my Feature File failing to find the Step Definition?
Your java is defined as a folder and not package try defining it as package and calling java.uk.co... if you see the folder...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Any solution for this? I’m stuck too with same need: feature files in a totally different path of steps.
update: I solved in this way:
with this configuration you can put
feature filesandstep definition filesin two totally different pathsTLDR
to have
.featurefiles in a different directory with the step definition, set thestepDefinitionsexacly the same as your cypressintegrationFolderandnonGlobalStepBaseDirto path to step definition folder.See last section for example
@goesbysteve I think I found the problem to the current behavior. There is this block of code in
cypress-cucumber-preprocessor/lib/getStepDefinitionsPaths.jsfile which will list all the files the modules need torequire(which is the step definitions)the problem is in this block of code
that code will run when we specify
nonGlobalStepBaseDirin the config. What that code does is get the path to yournonGlobalstepBaseDirchange your step definitions path to that and also change thecommonfolder path.But here’s the problem, the second line in the if block replace the current
nonGlobalPathpath that match with the result ofstepDefinitionPath()tostepBase. The value innonGlobalPathis the path to the.featurefile without the extension.The
stepDefinitionPathfunction supposed to return the path to step definitions. But currently this function will returnnonGlobalStepDefinitionsistrue, then return cwd +config.stepDefinitionsif it is notundefinedor return cwd +/cypress/integrationnonGlobalStepDefinitionsisfalse, then return cwd +config.stepDefinitionsif it is notundefined/cypress/support/step_definitionsSo basically it will return cwd +
stepDefinitionsor/cypress/integrationor/cypress/support/step_definitions, but thenonGlobalPathin the if block might not have all these value if our feature files is not in/cypress/integrationor/cypress/support/step_definitionsor in the directory we specify in thestepDefinitions(which supposed to be our step definitions folder), so the.replacefunction won’t change anything and thenonGlobalPathwill still have the path to your feature files without the extension. But the common folder is correct since it use thestepBasewhich is from thenonGlobalStepBaseDir.To have the
.featurefiles in a complete different directory with the step definitions, all we need to do is to specify the path to the root of step definitions file innonGlobalStepBaseDirand the path to the root of.featurefiles instepDefinitions.Make sure the path to step definition still follow the
cypress-cucumber-preprocessorconventionExample
your
cypress-cucumber-preprocessorconfig would looks like this:your cypress config would looks like this:
the
...means there is other configs there.You can check the
stepDefinitionPathfunction atcypress-cucumber-preprocessor/lib/stepDefinitionPath.jsI did not open a PR since I’m not sure which solution to use. My solution is:
stepDefinitionstofeatureFilesPathbut not sure if it will break anyintegrationFolderconfig value and use that for the.replacevalue