New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cucumber-js doesn't find step definitions #718
Comments
I know that cucumber-js is finding the step definitions file, because when I inject a syntax error into it, cucumber-js reports the error correctly. |
What version of cucumber-js are you using? |
It says 2.0.0-rc.6 |
Also a newbie and have the same issue running the same version of cucumber.js /features/add-item.feature
A world.js file has not be included at this point. |
@dunlop-ben please see the changelog about the difference between 1.0 and the 2.0 release candidates. The way of defining steps changed, and your example appears to be using the 1.0 syntax. @jeffmath nothing looks wrong to me. We have feature tests that verify something like your simple example works. Reproducing on a mac, it works as expected for me. What version of node are you running? And from the paths it appears you are on windows machine, is that correct? |
@charlierudolph - thanks. I have looked into this and tried a few different examples with a similar result. I have also tried using feature and step definition here: http://cucumber.github.io/cucumber-js/ I feel as though i must be missing a step and/or files. If there is anywhere you can direct me to that would be great. I haven't had much luck reading through the documentation on Github. |
@charlierudolph Node 6.4.0 on Windows 7 |
@charlierudolph I have similar problem. I exactly follow https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md and issue still occur. My setup is
|
For me it works if I'm writting |
Same error here: there is no way for cucumber to find the step definitions. Having the same folder structure works in linux.
Is there any way to force the step definitions path / folder / pattern? |
I am facing the same issue all of a sudden, the cucumber was fine executing the scripts until today morning. I have no idea what is wrong with it. I run the feature by rightclick on ruby mine and from command line using the command Can anyone please help
|
I had to downgrade to 1.3.1 to make it work.
It does not even work in centos.
…On 25 Jan 2017 21:32, "Mrityunjeyan S" ***@***.***> wrote:
I am facing the same issue all of a sudden, the cucumber was fine
executing the scripts until today morning. I have no idea what is wrong
with it.
I run the feature by rightclick on ruby mine and from command line using
the command cucumber -r features/chatstep.feature I get the same result.
Can anyone please help
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#718 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALjDKMNdggk1Gh-x_q3KRuvlpN5f_0cOks5rV7E9gaJpZM4LhJZO>
.
|
@jbgraug: what did u downgrade? What was Ur previous version before downgrade |
I tried with RC 2.0.6 & RC 2.0.0. I could not make it work in linux or
windows as cucumber was unable to find the step definitions, not even with
the -r option.
…On Thu, Jan 26, 2017 at 6:18 AM, Mrityunjeyan S ***@***.***> wrote:
@jbgraug <https://github.com/jbgraug>: what did u downgrade? What was Ur
previous version before downgrade
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#718 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALjDKGbyYXvsjlLv-dlz6bnHMfPK7t05ks5rWCypgaJpZM4LhJZO>
.
|
@jbgraug I guess the cucumber has deprecated the |
@reach2jeyan based on your command line and test snippets I believe you are talking about cucumber-ruby. While these two projects are related in trying to implement the cucumber framework for their respective languages, they have a number of differences. |
@charlierudolph Thanks for stepping in. My bad, I had actually not followed the step definition procedures earlier, plus, the cucumber-ruby versions were all messed up. I had to then reset everything and start all over again. It works now by the way! |
@charlierudolph exactly what @MartinDelille said, works fine via macOS + Node.js 7.5.0 + Cucumber.js 2.0.0-rc.7 |
@kozhevnikov thanks for the update. All the reports thus far had been on a windows (and I had unable to recreate on my local mac with the local install) Hard to imagine the global install is somehow different but at least now I can investigate. |
i get the same issues on windows using command prompt through cygwin maybe thats the issue? i even copied the code directly from the example. Feature: Simple maths Scenario: easy maths Scenario Outline: much more complex stuff
Cucumber.defineSupportCode(function(context) { ///// Your World ///// var CustomWorld = function() {}; CustomWorld.prototype.variable = 0; CustomWorld.prototype.setTo = function(number) { CustomWorld.prototype.incrementBy = function(number) { setWorldConstructor(CustomWorld); ///// Your step definitions ///// Given(/^a variable set to (\d+)$/, function(number) { When(/^I increment the variable by (\d+)$/, function(number) { Then(/^the variable should contain (\d+)$/, function(number) { i get this error "ReferenceError: Given is not defined" |
Alright. I believe I figured this out. When using a global install of cucumber to run the feature tests, you are still defining support code by requiring the local install of cucumber. The fact that these are two different instances results in no step definitions being loaded. Is there any reason you can't use the local install for running the command? I do this on mac by adding "./node_modules/.bin" to my path. I don't like the idea of trying to making this work by having the global install try to require the local install in order to get the step definitions. I also dislike the global install since it makes you have to specify things like compile modules by their absolute path. If this is possible on windows, I'd prefer to just update the documentation to mention that this cannot be used as a global install. |
Two minor points about removing global install:
|
Hmm. We can add a CLI option which allows the user specify where the local cucumber instance is? We can have the default be |
@charlierudolph After originally reporting the error, I realized I needed to be using Cucumber-JVM, anyway, since the code I was needing to test was written in Scala.js. But when I next need to test Javascript, your workaround sounds easy to implement. Thank you for figuring out the issue. |
It'll be tricky, from what I understand Node has lots of edge cases, so at a minimum it would have to traverse parents till it finds the local package or hits drive root, and I don't know how popular using global folders is in the Node community. |
@jeffmath @kozhevnikov here are my updated thoughts on this
|
I have found a similar problem while trying to build a library of common tests. My idea is to reuse tests across different projects. I have built a common tests package called roi-functional-tests that I would like to use in other projects. So far, I have linked the package with npm link and then try to point cucumber to the features in roi-functional-tests, something like this:
But I get this:
Can cucumber import definitions from outside of the working directory? |
@jramcast yes. But you would need to use the |
Already tried using the
But I get the same result. It is possible that |
So I did the same test without
My guess is that, when linking the package, |
Have the same problem. Cucumber version: "cucumber": "^2.0.0-rc.9" Does not work in IDE or global instance of cucumber, never finds the steps even though they are implemented correctly. If I call the cucumber.js from within the project's node_modules dir then it works. Anyone have any suggestions on how to fix this issue? This is also happening on MacOS Sierra 10.12.4 Went back to Cucumber version 1.3.0, works fine now calling it via cmd using global instance AND works in IDE. |
Hi @charlierudolph , |
I had Cucumber reference to 1.X versions in package-lock.json
I changed those two versions to 2,3,1 |
If you're using webdriverIO with its test runner as opposed to in standalone mode, you will NEED to use cucumber-js version 1.x, preferably 1.3.3 as opposed to 2.x as the test runner does NOT support the new version and new way the step definitions are implemented. I have gone back to the old Cucumber@1.3.3 as I am using the test runner which is required for page object model and ensuring all commands are run synchronously. |
@GeeChao When I tried the command with -r , I get syntex error in the feature file... C:\webdriverio-test\features\customer-validation.feature:2 SyntaxError: Unexpected identifier |
@vvedachalam Could you please create and push this to your repo so I can replicate it? |
@GeeChao |
Move your step_definitions folder within your features folder and it will start working and recognize the step definitions. Only issue that's thrown after is your txtdetails.txt file location is incorrect. |
@GeeChao Then why I am unable to glue the step definition to feature file in my local ? |
It works for me. The only thing I did was move step_definitions to under the features directory also i did a npm install cucumber@1.3.3 --save-dev then ran node_modules/cucumber/bin/cucumber.js features/ |
@GeeChao All worked fine. I made a For loop inside the Then statement which created the issue. Is it possible to use For loop inside step definition? |
@GeeChao Ok, again its my silly mistake. Looping variable was not set properly (forgot to compare the length). Thanks again for your support |
For me, as a newbie, the error was caused by me passing a string rather than a regex into the steps;
rather than
Simple mistake, but hopefully useful to someone else just starting out. |
@vvedachalam Did u sort it out? Could you please help |
@sancy2017 I moved to TestCafe tool from WDIO. So I may not be able to tell you the solution immediately. Let me know what exactly the problem that you are facing |
The simple solution for this error is npm install cucumber@1.3.3 --save-dev |
I ran into same problem "Cucumber Step definitions were not recognised". Changing the directory name from "steps" to "step_definitions" worked for me. I am seeing mostly people have step_definitions under features directory, i believe a better practice is to have the steps implementation in a separate directory i.e. src/step_definitions instead of keeping the steps under features directory. |
Hi, I'm a newbie who's been trying for hours to get cucumber-js to find my step definitions. I've come up with this simple example.
In features/foo.feature:
In features/step_definitions/step_defs.js:
I get this result:
The text was updated successfully, but these errors were encountered: