0

我失去了它,我觉得我做对了但无法弄清楚为什么这个简单的测试失败了

我有一个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 include name, name, name
    Then he should also see 1,2,3 in the list

我有一个definition像这样的文件

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

我有一个pageObject像这样的文件

export class AccountTable {
    // static displayingAll = Text.ofAll(AccountListUI.accountListView);
  // static isDisplayingAllNames = Text.ofAll(Target.the('account names in the table').located(by.css('table tbody tr td:nth-child(2)')));

  static AccountNames = Target.the('account names in the table').located(by.css('table tbody tr td:nth-child(2)'));
  static AccountNumbers = Target.the('account numbers in the table').located(by.css('table tbody tr td:nth-child(1)'));
  static isDisplayingAllNames = Text.ofAll(AccountTable.AccountNames);
  static isDisplayingAllNumbers = Text.ofAll(AccountTable.AccountNumbers);
}

这是我的课

constructor(private accName: string[]) {

  }

  static inTheTableOf(accName: string) {
    return new ViewAllAccountNames(accName);
  }

  performAs(actor: PerformsTasks): PromiseLike<void> {
    return actor.attemptsTo(
      See.if(AccountTable.isDisplayingAllNames, items => expect(items).to.eventually.contain(this.accName))
    );
  }
}

当我在课堂上通过 webstorm 进行调试时,ViewAllAccountNames我得到了

  static inTheTableOf(accName: string) { accName: Array(3)
    return new ViewAllAccountNames(accName); accName: Array(3)
  }

然后当我到达我的 See.if 函数时,我得到了

performAs(actor: PerformsTasks): PromiseLike<void> {
    return actor.attemptsTo(
      See.if(AccountTable.isDisplayingAllNames, items => expect(items).to.eventually.contain(this.accName)) AccountTable.isDisplayingAllNames: undefined
    );
  }

所以我的困境是这样的:我认为这源于我的 See.if 函数没有以正确的方式设置?

See.if(AccountTable.isDisplayingAllNames, items => expect(items).to.eventually.contain(this.accName))


Cucumber test run has failed.

1) Scenario: List all accounts in the tenant - e2e\features\get_account_list\get_all_accounts.feature:10
   Step: When he views the accounts in the table that include name, name, name - e2e\features\get_account_list\get_all_accounts.feature:12
   Step Definition: node_modules\serenity-js\src\serenity-cucumber\webdriver_synchroniser.ts:47
   Message:
     AssertionError: expected [ Array(5) ] to include [ 'name', 'name', 'name' ]
     From: Task: <anonymous>
4

1 回答 1

0

我是个白痴,我使用了错误的功能,不得不使用该功能

.to.eventually.contain.members

在这里找到类似的答案和描述: 答案

于 2018-04-13T17:15:22.567 回答