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