Cucumber-Protractor 多重期望和通知

Cucumber-Protractor Multiple Expect And Notify

我的方案中有一个步骤是填写多个文本字段并从下拉列表中选择选项。我想断言输入的文本和选择的选项都是正确的。

expect(action1).to.eventually.have.string('some text').and.notify(callback);
expect(action2).to.eventually.have.string('some text').and.notify(callback);
expect(action3).to.eventually.have.string('some text').and.notify(callback);

我遇到的问题是,如果第一个或第二个 expect 操作通过,那么任何后续操作都不会执行,从而导致误报。

理想情况下,我正在寻找一种在没有回调的情况下通知的方法,直到最后一次期望。有人知道如何做到这一点吗?

我实际上在另一个 Whosebug 问题中找到了我最初没有注意到的答案。

使用 Q 看起来像这样:

var Q = require('q');
var chai = require('chai');
var expect = chai.expect;
var should = chai.should();

Q.all([
  expect(action1).to.eventually.have.string('some text'),
  expect(action2).to.eventually.have.string('some text'),
  expect(action3).to.eventually.have.string('some text'),
]).should.notify(callback);