Logo: Relish

  1. Sign in

Project: Cucumber-js

World constructor callback with object

It is possible for the World constructor function to tell Cucumber
to use another object than itself as the World instance:

this.World = function WorldConstructor(callback) {
var myCustomWorld = { dance: function() { /* ... */ } };
callback(myCustomWorld); // tell Cucumber to use myCustomWorld
// as the world object.

If no parameter is passed to the callback, the WorldConstructor
instance will be used by Cucumber:

this.World = function WorldConstructor(callback) {
var myCustomWorld = {};
callback(); // could have been written callback(this);

scenario calling function on explicit world instance
a custom World constructor calling back with an explicit object
Cucumber executes a scenario that calls a function on the explicit World object
the feature passes
the explicit World object function should have been called

Last published almost 7 years ago by jbpros.