when.js
我正在为返回承诺的代码编写一些 Jasmine 单元测试。我不断发现自己在编写这样的代码:
doMyThing().then(function(x) {
expect(x).toEqual(42);
done();
}).otherwise(function() {
expect(true).toBe(false);
done();
});
捕获异常的唯一方法是使用函数(它是when.jsotherwise()
的旧版本),然后似乎没有 Jasmine(2.0)函数来表示“检测到故障” - 因此是 kludgy “ ”。expect(true).toBe(false)
有没有更惯用的方式来做到这一点?