Javascript 按照承诺,承诺的数组必须松散相等
有没有办法断言promise数组等于您的金标准,减去排序?深度相等失败,因为无法保证排序-阵列是异步构建的 据我所知,CaP不包括.should.finally.include.all[]或类似的内容。我不认为我能够检查每个条目,因为那样的话,notifydone将链接到哪里?插件可能会帮助您 例如,您可以执行以下操作:Javascript 按照承诺,承诺的数组必须松散相等,javascript,mocha.js,chai,chai-as-promised,Javascript,Mocha.js,Chai,Chai As Promised,有没有办法断言promise数组等于您的金标准,减去排序?深度相等失败,因为无法保证排序-阵列是异步构建的 据我所知,CaP不包括.should.finally.include.all[]或类似的内容。我不认为我能够检查每个条目,因为那样的话,notifydone将链接到哪里?插件可能会帮助您 例如,您可以执行以下操作: .should.eventually.include.something.that.equals(promiseA); .should.eventually.include.s
.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);
我希望这有帮助