mucsi96 / nightwatch-api

[DEPRECATED] Cross-runner API for Nightwatch.js
https://nightwatch-api.netlify.com/
MIT License
84 stars 64 forks source link

No way to define step-definitons/features not at the root directory when using cucumber. #949

Closed cmw9706 closed 3 years ago

cmw9706 commented 3 years ago

I have a project that I am using nightwatch api and cucumber with. Currently the locations of my nightwatch.conf.js ,cucumber.conf.js,step-definitions/ ,and features/ are all in my root dir of my project. I can run my test using the script

cucumber-js --require-module @babel/register --require cucumber.conf.js --require step-definitions

and everything runs as expected.

I would like to be able to put my step definitions/ and my feature/ directories to a e2e/ directory and achieve the same results. However this seems to not work.

Whenever I most my directories to myproject/tests/e2e/, i tried modifying the required directory to match, so now my script looks like this

cucumber-js --require-module @babel/register --require cucumber.conf.js --require ./tests/e2e/step-definitions

But now the CLI output just says 0 scenarios found.

I have also tried setting the src_folder property in the nightwatch.conf.js and have this didn't work either. Any help would be greatly appreciated.

Expected Behavior

I can put my step definitions and feature directories somewhere other than the root directory and they will be recognized when I run my test

Current Behavior

The step definitions and feature directories must be at my root directory for them to be recognized by the cucumber command

cmw9706 commented 3 years ago

Solved

In the event that anyone else ended up here with the same issue, here is my solution. Turns out I just didn't read enough of the cucumber cli documentation and tbh I'm not sure I think its very well described but, cucumber-js takes a positional argument defining the location of your feature directory and it takes a --require argument defining the location of your step-definitions.

The script I ended up running to get this to work looks like this,

cucumber-js tests/e2e/features --require-module @babel/register --require cucumber.conf.js --require tests/e2e/step-definitions

Reference