2017-02-27 52 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);