How do I properly test promises with mocha and chai?
The easiest thing to do would be to use the built in promises support Mocha has in recent versions: it(‘Should return the exchange rates for btc_ltc’, function() { // no done var pair=”btc_ltc”; // note the return return shapeshift.getRate(pair).then(function(data){ expect(data.pair).to.equal(pair); expect(data.rate).to.have.length(400); });// no catch, it’ll figure it out since the promise is rejected }); Or … Read more