黄瓜.js类型错误: 无法读取未定义的属性'pending'



我使用Node.js、cucumber.js(全局安装)和Web Storm IDE,并使用了一个简单的加法场景,我得到了以下错误。步骤定义除了callback.pending之外没有其他内容。有什么想法吗?

TypeError:无法读取未定义的属性"挂起"在世界。(/Users/wfn936/Repos/customer svc/features/step_definitions/customer.js:6:17)在Object.invoke(/usr/local/lib/node_modules/cuckle/lib/cucument/support_code/step_definition.js:88:14)在Object.execute(/usr/local/lib/node_modules/ccucument/lib/cucument/ast/step.js:161:22)在Object.acceptVisitor(/usr/local/lib/node_modules/ccucument/lib/cucument/ast/step.js:147:12)在Object.executeStep(/usr/local/lib/node_modules/ccucument/lib/cucument/runtime/ast_tree_walker.js:296:12)在Object.prrocessStep上(/usr/local/lib/node_modules/cuckle/lib/cucument/runtime/ast_tree_walker.js:291:14)位于/usr/local/lib/node_modules/ccucument/lib/cucument/runtime/ast_tree_walker.js:129:16在callUserFunctionAndBroadcastAfterEvent(/usr/local/lib/node_modules/ccucument/lib/cucument/runtime/ast_tree_walker.js:153:9)在迭代时(/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:55:11)位于/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:62:11位于Object.hear(/usr/local/lib/node_modules/cuckle/lib/cucump/listener.js:8:9)位于/usr/local/lib/node_modules/ccucument/lib/cucument/runtime/ast_tree_walker.js:179:52在processItem(/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:61:9)在迭代时(/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:53:11)位于/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:62:11位于Object.hear(/usr/local/lib/node_modules/cuckle/lib/cucump/listener.js:8:9)位于/usr/local/lib/node_modules/ccucument/lib/cucument/runtime/ast_tree_walker.js:179:52在processItem(/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:61:9)在迭代时(/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:53:11)位于/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:62:11位于Object.hear(/usr/local/lib/node_modules/cuckle/lib/cucump/listener.js:8:9)位于/usr/local/lib/node_modules/ccucument/lib/cucument/runtime/ast_tree_walker.js:179:52在processItem(/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:61:9)在迭代时(/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:53:11)位于/usr/local/lib/node_modules/ccucument/lib/cucument/type/collection.js:62:11在handleBeforeScenarioEvent(/Applications/WebStorm.app/Contents/plugins/CuccumberJavaScript/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;

此错误

TypeError:无法读取World中未定义的属性"pending"。(/Users/wfn936/Repos/customer svc/features/step_definitions/customer.js:6:17)在。。。

当捕获的参数数量与提供的回调中的参数不匹配时发生

但在你的情况下,一切看起来都很好。

我建议你重新安装黄瓜(也许)再次检查您的功能和步骤定义文件

  • 它们真的像你发布的吗
  • 你使用这些文件吗(或者可能是其他带有其他内容的文件)

注意:

  • /^I have number (d+) and (d+)$/这样的Regexp必须具有回调function (arg1, arg2, callback) {}

  • /^I have number (d+)$/这样的Regexp必须具有回调function (arg1, callback) {}

最新更新