According to the Cucumber-js documentation, utilities should be made available by creating a constructor function called World
. In Chimp, this constructor already exists, creating a world loaded with utility.
How do I extend this constructor to add my own utilities?
I tried:
function sayHi() {
console.log('Hi!');
}
module.exports = function() {
var ChimpWorld = this.World;
this.World = function() {
this.sayHi = sayHi;
ChimpWorld.call(this);
}
};
Which results in:
/Users/thomasvanlankveld/.nvm/v0.12.4/lib/node_modules/chimp/node_modules/fibers/future.js:267
throw(ex);
^
TypeError: undefined is not a function
at [object Object].World (/Users/thomasvanlankveld/.nvm/v0.12.4/lib/node_modules/chimp/lib/cucumberjs/world.js:21:7)
at new World (/Users/thomasvanlankveld/Sites/my-app/tests/features/world.js:9:16)
at Array.<anonymous> (/Users/thomasvanlankveld/.nvm/v0.12.4/lib/node_modules/chimp/lib/cucumberjs/cucumber-wrapper.js:137:24)
at Object.Future.return (/Users/thomasvanlankveld/.nvm/v0.12.4/lib/node_modules/chimp/node_modules/fibers/future.js:262:13)
at Object.<anonymous> (/Users/thomasvanlankveld/.nvm/v0.12.4/lib/node_modules/chimp/node_modules/fibers/future.js:336:16)
at /Users/thomasvanlankveld/.nvm/v0.12.4/lib/node_modules/chimp/node_modules/underscore/underscore.js:890:21
at /Users/thomasvanlankveld/.nvm/v0.12.4/lib/node_modules/chimp/lib/cucumberjs/cucumber-wrapper.js:127:19
So it seems Chimp's World
constructor is not available to me.
In case this is not possible, is there another way to make my own helpers available across files?
Aucun commentaire:
Enregistrer un commentaire