2017-02-27 71 views
0

我在我的方案中有一个步骤,填充多个文本字段并从下拉列表中选择选项。我想断言输入的文本和选择的选项对每个都是正确的。黄瓜量角器多个期望和通知

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

我遇到的问题是,如果在第一或第二期望的操作,然后通过以下任何操作将不会得到执行,导致误报。

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

回答

0

我实际上在另一个StackOverflow问题中找到了答案,我最初没有注意到它。使用

How does one use Q.all with chai-as-promised?

e它应该是这样的:

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