我正在使用Browser Runner在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)
所以很明显它捕捉到了错误,只是没有正确地显示出来。你知道该怎么做吗?我想我可以用一个错误对象来调用"done“,但这样我就失去了像Chai这样的东西的优雅,它变得非常笨拙……
https://stackoverflow.com/questions/11235815
复制相似问题