我有以下代码...
// support/world.js
/*jslint node: true */
"use strict";
var zombie = require('zombie');
var WorldConstructor = function WorldConstructor(callback) {
this.browser = new zombie();
var world = {
visit: function(url, callback){
this.browser.visit(url, callback);
}
};
callback(world); // tell Cucumber we're finished and to use our world object instead of 'this'
};
exports.World = WorldConstructor;
// step_definition/note_steps.js
var noteStepDefinitionWrapper = function() {
this.World = require("../support/world.js").World; // overwrite default
// World constructor
this.Given(/^I am on the main page$/, function(callback) {
console.log("Step 1");
// console.log(JSON.stringify(require("../support/world.js").World));
this.visit('http://localhost:8080', callback);
});
this.When(/^I click the add button$/, function(callback) {
console.log("Step 2")
callback();
});
this.When(/^I fill out question information$/, function(callback) {
console.log("Step 3")
callback();
});
this.When(/^I click submit$/, function(callback) {
console.log("Step 4")
callback();
});
this.Then(/^I should see the new question$/, function(callback) {
console.log("Step 5")
callback();
});
};
module.exports = noteStepDefinitionWrapper;
但是当我尝试运行它时,我得到以下...
TypeError: Cannot read property 'visit' of undefined
at Object.WorldConstructor.world.visit (***/grails-angular/src/test/features/support/world.js:8:18)
我在这里想念什么?