0

I have a feature file with:

  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

I have a steps definition file with:

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

here is the ViewAllAccountNames class that's being called in the steps definition

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))
        );
    }

so given all that info, I run the test and keep getting function has 1 arguments, should have 2 (if synchronous or returning a promise) or 3 (if accepting a callback) (below is the error)

I cant tell if its breaking on the argument or an error inside my code

any ideas?

[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)
4

1 回答 1

4

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

将回调作为参数传递:

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

让函数返回一个承诺:

this.When(/^(.*?) views the accounts in the table that include (.*)$/, function(accountInformation: string) {
    return stage.theActorInTheSpotlight().attemptsTo(
        ViewAllAccountNames.inTheTableOf(accountInformation)
    );   
});
于 2018-04-30T17:29:31.987 回答