我正在使用Node.js,cucumber.js(全局安装)和带有简单添加号码场景的Web Storm IDE,我收到以下错误。除了callback.pending之外,步骤定义没有其他任何内容。 有什么想法吗?
TypeError:无法读取undefined的属性“pending” 在世界。 (/Users/wfn936/Repos/customer-svc/features/step_definitions/customer.js:6:17) at Object.invoke(/usr/local/lib/node_modules/cucumber/lib/cucumber/support_code/step_definition.js:88:14) at Object.execute(/usr/local/lib/node_modules/cucumber/lib/cucumber/ast/step.js:161:22) at Object.acceptVisitor(/usr/local/lib/node_modules/cucumber/lib/cucumber/ast/step.js:147:12) at Object.executeStep(/usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:296:12) at Object.processStep(/usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:291:14) at /usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:129:16 at callUserFunctionAndBroadcastAfterEvent(/usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:153:9) 在iterate(/usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:55:11) at /usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:62:11 at Object.hear(/usr/local/lib/node_modules/cucumber/lib/cucumber/listener.js:8:9) at /usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:179:52 at processItem(/usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:61:9) 在iterate(/usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:53:11) at /usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:62:11 at Object.hear(/usr/local/lib/node_modules/cucumber/lib/cucumber/listener.js:8:9) at /usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:179:52 at processItem(/usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:61:9) 在iterate(/usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:53:11) at /usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:62:11 at Object.hear(/usr/local/lib/node_modules/cucumber/lib/cucumber/listener.js:8:9) at /usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:179:52 at processItem(/usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:61:9) 在iterate(/usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:53:11) at /usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:62:11 在handleBeforeScenarioEvent(/Applications/WebStorm.app/Contents/plugins/CucumberJavaScript/lib/cucumberjs_formatter_nix.js:97:9)
Feature: As a math learner
I want to add two numbers
so that I can learn how to add
Scenario:
Given I have number 3 and 5
When I add them
Then I get 8 as result
var myStepDefinitionsWrapper = function () {
this.Given(/^I have number (\d+) and (\d+)$/, function (arg1, arg2, callback) {
callback.pending();
});
this.When(/^I add them$/, function (callback) {
callback.pending();
});
this.Then(/^I get (\d+) as result$/, function (arg1, callback) {
callback.pending();
});
};
module.exports = myStepDefinitionsWrapper;
答案 0 :(得分:1)
此错误
TypeError:无法在World处读取未定义的属性“待定”。 (/Users/wfn936/Repos/customer-svc/features/step_definitions/customer.js:6:17)at ...
在捕获的args数与提供的回调中的args不匹配时发生
但在你的情况下,一切看起来都不错。
我建议你重新安装黄瓜(也许) 再次检查您的功能和步骤定义文件
注意:强>
/^I have number (\d+) and (\d+)$/
等正则表达必须有回调function (arg1, arg2, callback) {}
/^I have number (\d+)$/
等正则表达必须有回调function (arg1, callback) {}