1

現在、要素をクリックすると別の要素の値が最終的に変化することを主張するテストを作成しようとしています。私は次のことを試しました:

it 'should change the value of the ec when the Scheduled option is clicked', ->
    element(By.css("li[title='Scheduled']")).click()
    expect(stateEc.getText()).to.eventually.equal("Scheduled")

上記のテストは、予期した時点で stateEc 要素のテキストが "Ongoing" だったため失敗しました。次に、次を追加しました

 it 'should change the value of the ec when the Scheduled option is clicked', ->
    element(By.css("li[title='Scheduled']")).click()
    browser.wait( () ->
      return stateEc.getText().then (text) ->
        text is "Scheduled"
      , 2000)

    expect(stateEc.getText()).to.eventually.equal("Scheduled")

テストは毎回パスするようになりました - 問題は、私がこのソリューションを嫌い、正直に言うと、chai-as-promised の目的は、特定の制限時間内に真になる必要のあるアサーションを作成できることだと思ったことです。私は何を間違っていますか?

4

0 に答える 0