我刚开始使用Qunit,想知道是否有办法捕获/验证/省略警报,例如:
function to_test() {
alert("I'm displaying an alert");
return 42;
}
Run Code Online (Sandbox Code Playgroud)
然后有类似的东西:
test("to_test", function() {
//in this case I'd like to test the alert.
alerts("I'm displaying an alert", to_test(), "to_test() should display an alert");
equals(42, to_test(), "to_test() should return 42" ); // in this case I'd like to omit the alert
});
Run Code Online (Sandbox Code Playgroud)
我对使用其他单元测试工具的建议持开放态度.
提前致谢!