黄瓜函数有 1 个参数,应该有 2 个(如果同步或返回承诺)

cucumber function has 1 arguments, should have 2 (if synchronous or returning a promise)

我有一个 feature 文件:

  Scenario: List all accounts in the tenant
    Given that Keith has navigated to the tenant account list
    When he views the accounts in the table that includes name, name2, name3
    Then he should also see 1,2,3,4 in the list

我有一个步骤定义文件:

this.When(/^(.*?) views the accounts in the table that include (.*)$/, (accountInformation: string) => {
    return stage.theActorInTheSpotlight().attemptsTo(
      ViewAllAccountNames.inTheTableOf(accountInformation)
    );   });

这是在步骤定义中调用的 ViewAllAccountNames class

constructor(private accName: string) {

  }
    static inTheTableOf(accName: string) {
        return new ViewAllAccountNames(accName);
    }
    performAs(actor: PerformsTasks): PromiseLike<void> {
        return actor.attemptsTo(
          See.if(AccountTable.isDisplayingAll, includes(this.accName))
        );
    }

所以鉴于所有这些信息,我 运行 test and keep getting 函数有 1 个参数,应该有 2 个(如果同步或返回承诺)或 3(如果接受回调)(下面是错误)

我无法判断它是否破坏了参数或我的代码中的错误

有什么想法吗?

[16:25:27] I/launcher - Running 1 instances of WebDriver
[16:25:27] I/local - Starting selenium standalone server...
[16:25:29] I/local - Selenium standalone server started at http://10.4.31.17:63444/wd/h
ub
Feature: Manage the accounts associated with the tenant

    In order to see all accounts for a customer
    Keith would like view all accounts in the Account List
    Keith would like the account list to display accounts containing Account information

  Scenario: List all accounts in the tenant
  √ Given that Keith has navigated to the tenant account list
  × When he views the accounts in the table that includes name,name2,name3
  - Then he should also see 1,2,3,4 in the list

Failures:

1) Scenario: List all accounts in the tenant - e2e\features\get_account_list\get_all_ac
counts.feature:10
   Step: When he views the accounts in the table that include name - e2e\features\get_a
ccount_list\get_all_accounts.feature:12
   Step Definition: node_modules\serenity-js\src\serenity-cucumber\webdriver_synchronis
er.ts:47
   Message:
     function has 1 arguments, should have 2 (if synchronous or returning a promise) or
 3 (if accepting a callback)

1 scenario (1 failed)
3 steps (1 failed, 1 skipped, 1 passed)

它期望回调参数作为第二个参数。有两种方法可以解决这个问题。

将回调作为参数传递:

this.When(/^(.*?) views the accounts in the table that include (.*)$/, (accountInformation: string, callback) => {
    stage.theActorInTheSpotlight().attemptsTo(
        ViewAllAccountNames.inTheTableOf(accountInformation)   
    ).then(callback, callback);
});

使函数 return 成为承诺:

this.When(/^(.*?) views the accounts in the table that include (.*)$/, function(accountInformation: string) {
    return stage.theActorInTheSpotlight().attemptsTo(
        ViewAllAccountNames.inTheTableOf(accountInformation)
    );   
});