How to add packages require()'d by tests


#1

Hi all,

In a cucumber feature_steps.js file, I want to use chai, so I write:

chai = require('chai');

However, cucumber fails saying that that it can’t find the module chai, even though it is used by xolvio:cucumber itself. I can get things to work with:

cd tests/cucumber
mkdir node_modules
cd node_modules
ln -s ~/.meteor/packages/xolvio_cucumber/.0.6.0.skb9g1++os+web.browser+web.cordova/npm/node_modules/chai .

Is that the correct approach or is there a better way? If that is the correct approach, is there a way to ensure that other developers get chai installed in the correct spot without adding tests/cucumber/node_modules to my git repo?

Thanks!

P.S. I’m a node/meteor/velocity/cucumber noob so I could be missing something really obvious here.


#2

http://docs.meteor.com/#/full/Npm-depends

But it’s packages only


#3

Thanks! That’s what I needed. I just created and added my own chai meteor package that uses Npm.depends to pull in the chai npm module.


#4

Hey Brettle

What’s your use-case? I ask because xolcio:cucumber comes with chai baked in.


#5

I want to call chai.should() within a cucumber feature_steps.js file to enable should style. So I call:

chai=require('chai');
chai.should()

That causes cucumber to fail with an inabiltly to resolve ‘chai’.


#6

This is already done for you :wink: Check out this line:

https://github.com/xolvio/cuke-monkey/blob/develop/lib/cucumberjs/world.js#L14

You can just call should like this:

https://github.com/xolvio/cuke-monkey/blob/develop/features/step_definitions/webdriver-steps.js#L11

Notice how you can also use chai-as-promised to save yourself some ugly callback nesting


#7

Good to know, but there doesn’t appear to be access to the ‘should’ object
(as opposed to the ‘should’ property). Typical usage looks like this:

should = chai.should();
should.exist(var_which_could_be_undefined);


#8

I understand

If you put a feature request on cucumber (github issues) I can have it on my list for a future release


#9

Done. It’s issue 327.