2017-06-08 6 views
0

expectステートメントが失敗しても、私のキュウリのステップが成功しません。 expectステートメントが完了する前にステップが実行されているようです。expectが失敗したはずのCucmber.jsのステップが完了しました

私は、キュウリのステップに、期待していない場合に失敗するよう指示する方法を教えてください。

は、[フォルダ構造]続いて後

私のフィーチャーファイルで、私は以下のようにステップ次に書く場合はすべてがうまく機能ステップ定義

var chai = require('chai'), 
    expect = chai.expect, 
    chaiAsPromised = require('chai-as-promised'); 
chai.use(chaiAsPromised); 

chai.should(); 

var {defineSupportCode} = require('cucumber'); 
let scenarioTimeout = 200 * 1000; 

defineSupportCode(({setDefaultTimeout}) => { 
    setDefaultTimeout(scenarioTimeout); 
}); 

defineSupportCode(function({Given, When, Then}) { 
  Given(/^I go to "([^"]*)"$/, function(site) { 
    return browser.get(site); 
  }); 

  When(/^I add "([^"]*)" in the task field$/, function(task) { 
    return element(by.model('todoList.todoText')).sendKeys(task); 
  }); 

  When(/^I click the add button$/, function() { 
    var el = element(by.css('[value="add"]')); 
   return el.click(); 
  }); 

  Then(/^I should see my new task in the list$/, function() { 
    var todoList = element.all(by.repeater('todo in todoList.todos')); 
    return expect(todoList.get(2).getText()).to.eventually.equal('Not Awesome'); 


  }); 
}); 

です:

解決策1:

element.all(by.repeater('todo in todoList.todos')).then(function(items){ 
expect(items[2].getText()).to.eventually.equal('Not Awesome').and.notify(callback); 
}); 

対処方法2:

Then(/^I should see my new task in the list$/, function() { 

var todoList = element.all(by.repeater('todo in todoList.todos')); 
    return expect(todoList.get(2).getText()).to.eventually.equal('Not Awesome'); 

答えて

0

私は最終的に解決するために管理:

return element.all(by.repeater('todo in todoList.todos')).then(function(items){ 
return expect(items[2].getText()).to.eventually.equal('Not Awesome'); 
}); 

私は本当に私はその後、以下の方法のステップを書かれている場合、それが機能しなかった理由を理解したいです問題。

チャイ-AS-約束のバージョンは6.0であり、それは、依存関係をピアチャイバージョン> = 2.1.2 私は> 4チャイバージョンを持っていたであるので、私はバージョン2.1.2にダウングレードし、それはすべてスムーズに働い。

関連する問題