[JS] beforeEach throwing error

1,036 views
Skip to first unread message

Dovie Gelerinter

unread,
May 14, 2013, 4:04:05 PM5/14/13
to cu...@googlegroups.com
So, due to the extreme kindness and patience of a fellow user on here, I got my cucumber.js all set up with zombie behind it.  However, now I have a new issue that I can't seem to figure out. This whole thing is new to me, so I apologize if some of my errors are common ones.

When I run "cucumber-js myfeature.feature" I get an error in <projfold>\node_modules\cucumber\spec\support\spec_helper.js on the first line where it says beforeEach and it's saying:

ReferenceError: beforeEach is not defined.

How do I deal with that?

I'm running node v.0.8 (cucumber.js complained when I tried to install it on 10 and, for the record, I tried it also and got the same error)
cucumber.js version 0.3.0
Windows XP
I'm using the node command prompt to do all this.

Not sure what other information you might need, please just ask.

Thanks!

Julien Biezemans

unread,
May 16, 2013, 7:51:45 AM5/16/13
to cu...@googlegroups.com
On Tue, May 14, 2013 at 10:04 PM, Dovie Gelerinter <geleri...@gmail.com> wrote:
So, due to the extreme kindness and patience of a fellow user on here, I got my cucumber.js all set up with zombie behind it.  However, now I have a new issue that I can't seem to figure out. This whole thing is new to me, so I apologize if some of my errors are common ones.

When I run "cucumber-js myfeature.feature" I get an error in <projfold>\node_modules\cucumber\spec\support\spec_helper.js on the first line where it says beforeEach and it's saying:

ReferenceError: beforeEach is not defined.


This spec_helper.js file is part of Cucumber.js's own unit test suite. It is NOT supposed to be loaded by your test suite.

Why is this happening you ask? :) Here is the explanation:

When you tell Cucumber to execute a feature file, Cucumber will look for "support code" (i.e. your step definitions and other code needed to run the tests) in the same directory the feature file reside in and its child directories.

In your situation, it means the following is happening:

1. Cucumber is loading <projfold>\features\myfeature.feature
2. Cucumber looks for *.js in <projfold>\features\ and all its sub-directories (including node_modules which is the one containing all your Node module files). Those files are automatically executed by Cucumber before starting the very first scenario. This is how your step definitions, hooks and testing code are supposed to be executed. 

The problem here is that your feature file(s) is residing in the same directory as your node_modules directory.

What I suggest is to remove the node_modules directory from there, go one level up in the folder hierarchy (<projfold>) and do your "npm install cucumber zombie" in there. This will create the node_modules directory in <projfold>, making the features directory effectively isolated from the rest. Cucumber will automatically load features in the "features" sub-directory if you call it from <projfold>, too.

Another way would be to move node_modules one level up, but I'm not sure this will work, from the perspective of NPM. You can try that first and if things are break, try the previous suggestion.

HTH,

- Julien.
 
How do I deal with that?

I'm running node v.0.8 (cucumber.js complained when I tried to install it on 10 and, for the record, I tried it also and got the same error)
cucumber.js version 0.3.0
Windows XP
I'm using the node command prompt to do all this.

Not sure what other information you might need, please just ask.

Thanks!

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages