3
我正在用QUnit编写一系列使用sinon存根的测试。测试的方法有自定义插件的依赖,我们将调用foo,这我碰伤了这样:Stubbing jQuery.fn方法在Chrome和Firefox中正常工作,IE8失败
// setup
var stub = this.stub(jQuery.fn, "Foo").returns("");
// run
someProprietyMethod();
// assertions
equal(stub.args.length, 3);
equal(stub.args[0], "bar");
equal(stub.thisValues[0], "#some-selector");
// other assertions
我发现使用兴农存根非常方便和直观相比手动创建存根。问题是,这在Chrome和Firefox中运行良好,但不是IE8。
对于IE8的测试结果我得到:
Died on test #1 undefined: Object doesn't support this property or method
在测试代码放置一些调试面包屑,它看起来像$()Foo和$ .fn.Foo都被看作是方法,但是。在$(“#some-selector”)后测试停止运行。在IE8中运行时调用Foo()。
什么是$(“#some-selector”),什么元素? – Huangism
@黄色这是一个输入,将用于某些专有方法()。存根.Foo()使这无关紧要。 – Martin
euaul是否是错字?不知道我明白... – mjwenk