【发布时间】:2015-07-13 23:06:06
【问题描述】:
我使用的是诗浓 1.14。我想使用 Sinon 的存根抑制所有 javascript 警报。
使用最新的 Chrome 版本:42.0.2311.135 m,我收到异常:“尝试包装已包装的警报”
下面的代码在最新的 Firefox 中运行良好。我会用小提琴更新。
var hooks = {
beforeEach: function(assert){
this.sandbox = sinon.sandbox.create();
this.sandbox.stub(window, 'alert', function (msg) { return false; });
},
afterEach: function(){
this.sandbox.restore();
}
};
module('example', hooks);
test('example', function(assert){
ok(true, 'does not throw an exception');
});
【问题讨论】:
标签: javascript qunit sinon