2017-09-28 6 views
0

私は分度器でキュウリのテストステップを作成したいと思いましたが、私は予想ステップに入っています。 '2019'は無視できません。 。 はここに私のソースコードである:期待(yearString).to.eventually.containでタイプエラー '2019'は有効ではありません

 this.Then(/^I check that the calculated year from the current month\(if current month >= 6 ==> current year = current year \+ 2,else current year = current year \+ 1\)$/,function(callback) { 

      var actualDate=new Date(); 
      var actualYear=actualDate.getFullYear(); 
      var actualMonth=actualDate.getMonth()+1; 
      //expect(targetAmountPO.getYesInflationLabel().isDisplayed()).eventually.to.equal(true).then(callback); 
      targetAmountPO.getYesInflationLabel().isDisplayed().then(function() { 
       targetAmountPO.getYesInflationCorrectionAnswer().isSelected().then(function(){ 
        targetAmountPO.getYesInflationLabel().getAttribute("outerText").then(function(text,callback){ 
         //console.log(text); 
         var splittedString=text.split(":"); 
         //console.log(splittedString[1]); 
         if(actualMonth>=6) 
         { 
          actualYear+=2; 
          var yearString=actualYear.toString(); 
          console.log(yearString); 
          expect(yearString).to.eventually.contain(splittedString[1]).and.notify(callback); 

          //console.log(actualYear); 

         } 
         else 
         { 
          expect(actualYear+1).to.include(splittedString[1]).and.notify(callback); 

         } 

       }) 

       }) 

      }) 


     }) 

(splittedString [1])(コールバック)をand.notify。

私は '2019'を得ることはできません。 yearStringは2019が良いです。 しかし、なぜ可決できないのですか?

私を助けることができますか?

答えて

1

あなたは適切にあなただけの

expect(yearString).to.contain(splittedString[1]) 
callback() 
のように約束したアサーションとしてチャイアサーションではなくチャイを使用できるように yearStringsplittedStringの値だけで、実際の値ではなく約束され getAttribute("outerText")によって返された約束を扱ってきたように

とすると、アサーションが実際にチェックを行う前にコールバックしないようにテストすることができます

+0

ありがとうRoss。 私はJAVA開発者ですが、AngularJS E2Eテストを受けました。 – user3654435

関連する問題