【发布时间】:2014-11-16 19:38:26
【问题描述】:
有没有办法断言承诺数组等于您的黄金标准,减去排序?深度相等失败,因为无法保证排序 - 数组是异步构建的。
据我所知,CaP 不包含“.should.eventually.include.all([])”或类似的东西。我认为我无法检查每个条目,因为那样的话 notify(done) 会被链接到哪里?
【问题讨论】:
标签: javascript mocha.js chai chai-as-promised
有没有办法断言承诺数组等于您的黄金标准,减去排序?深度相等失败,因为无法保证排序 - 数组是异步构建的。
据我所知,CaP 不包含“.should.eventually.include.all([])”或类似的东西。我认为我无法检查每个条目,因为那样的话 notify(done) 会被链接到哪里?
【问题讨论】:
标签: javascript mocha.js chai chai-as-promised
Chai Things 插件可能会对您有所帮助。
例如,您可以执行以下操作:
.should.eventually.include.something.that.equals(promiseA);
.should.eventually.include.something.that.equals(promiseB);
.should.eventually.include.something.that.equals(promiseC);
【讨论】:
如果我正确理解您的问题,您应该可以这样做:
Promise.all(arrayOfPromises).then(function (results) {
//so check your results here
for (var i = 0; i < results.length; i++) {
results[i].should.have....
}
//and the notify(done) is chained after this
}).should.eventually.notify(done);
希望对你有帮助。
【讨论】: