cucumber-js doesn't find step definitions
See original GitHub issueHi, 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:
Feature: Foo
Scenario: Bar
Given FooBar
In features/step_definitions/step_defs.js:
var {defineSupportCode} = require('cucumber');
defineSupportCode(function({Given}) {
Given('FooBar', function () {
return 'pending';
});
});
I get this result:
Feature: Foo
Scenario: Bar
? Given FooBar
Warnings:
1) Scenario: Bar - features\foo.feature:2
Step: Given FooBar - features\foo.feature:3
Message:
Undefined. Implement with the following snippet:
Given('FooBar', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
1 scenario (1 undefined)
1 step (1 undefined)
0m00.000s
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:48 (13 by maintainers)
Top Results From Across the Web
Cucumber not seeing steps in javascript project - Stack Overflow
I believe you need to have features and step_definitions folders in the same directory for cucumber to find step definitions.
Read more >can't run cucumber is step definitions are located in non ...
WebStorm 2019.2 (now available as an Early Access Preview) can detect Cucumber.js step definitions located in folders other than the step_definitions folder.
Read more >Was unable to find a step for “”: Mapping stepDefinitions to ...
While working with cucumber, when steps are not mapped completely with the feature files, it usually gives this as a warning.
Read more >FAQ - Cucumber Documentation
If Cucumber is telling you that your steps are undefined, when you have defined step definitions, this means that Cucumber cannot find your...
Read more >cucumber/cucumber-js - Gitter
In fact, the 'before' hook code does not seem to get executed at all for the second ... I have a question regarding...
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 FreeTop 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
Top GitHub Comments
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.
@vvedachalam
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/