我正在使用浏览器运行程序在Mocha中运行一些异步测试,并且尝试使用Chai的Expect样式声明:
window.expect = chai.expect;
describe('my test', function() {
it('should do something', function (done) {
setTimeout(function () {
expect(true).to.equal(false);
}, 100);
}
}
这不会给我正常的失败断言消息,相反,我得到:
Error: the string "Uncaught AssertionError: expected true to equal false" was thrown, throw an Error :)
at Runner.fail (http://localhost:8000/tests/integration/mocha/vendor/mocha.js:3475:11)
at Runner.uncaught (http://localhost:8000/tests/integration/mocha/vendor/mocha.js:3748:8)
at uncaught (http://localhost:8000/tests/integration/mocha/vendor/mocha.js:3778:10)
因此,显然是在捕获错误,只是没有正确显示它。任何想法如何做到这一点?我想我可以用一个错误对象调用“完成”,但是然后我失去了像柴一样的优雅,它变得笨拙...