Javascript qunit与各种其他进口产品的性能
我想做一个简单的测试,看看我是否掌握了投掷的工作原理。所以我为自己树立了一个榜样,但它崩溃了,我不知道为什么Javascript qunit与各种其他进口产品的性能,javascript,qunit,Javascript,Qunit,我想做一个简单的测试,看看我是否掌握了投掷的工作原理。所以我为自己树立了一个榜样,但它崩溃了,我不知道为什么 asyncTest('Testing submission system', function(){ ... // Decaration of the mockCreators throws(function(){ // Text book example throw 'error' }, 'throws an error') main
asyncTest('Testing submission system', function(){
... // Decaration of the mockCreators
throws(function(){ // Text book example
throw 'error'
}, 'throws an error')
mainView.registerSave(mockCreator);
mainView.registerSave(mockCreator2);
mainView.registerSave(mockCreator3);
mainView.registerSave(mockCreator4);
throws(mainView.registerSave(mockCreator2), 'also throws an error')
mainView.startParsing();
});
我的实际mainView.registerSave
:
registerSave: function(object)
{
if(typeof(object.model) === 'undefined')throw 'Crash: Missing "model" attribute'
if(typeof(object.parseData) !== 'function')throw 'Crash: Missing "parseData" function'
if(typeof(object.saveData) !=='function')throw 'Crash: Missing "saveData" function'
if(_.indexOf(this.subscribed, object) !== -1)throw 'Save already registered'
this.subscribed.push(object);
},
mainView
从Backbone.views扩展而来
坠机事件:
Died on test #2 at QUnit.asyncTest (http://localhost:8080/JSLib/qunit-1.14.0.js:108:9)
at HTMLDocument.<anonymous> (http://localhost:8080/CreateStory/testCreateStory.js:292:2)
at fire (http://localhost:8080/JSLib/jquery-1.11.1.js:3119:30)
at Object.self.fireWith [as resolveWith] (http://localhost:8080/JSLib/jquery-1.11.1.js:3231:7)
at Function.jQuery.extend.ready (http://localhost:8080/JSLib/jquery-1.11.1.js:3443:13)
at HTMLDocument.completed (http://localhost:8080/JSLib/jquery-1.11.1.js:3474:10): Save already registered
在QUnit.asyncTest的测试#2中死亡(http://localhost:8080/JSLib/qunit-1.14.0.js:108:9)
在HTMLDocument。(http://localhost:8080/CreateStory/testCreateStory.js:292:2)
着火(http://localhost:8080/JSLib/jquery-1.11.1.js:3119:30)
在Object.self.fireWith[作为resolveWith](http://localhost:8080/JSLib/jquery-1.11.1.js:3231:7)
位于Function.jQuery.extend.ready(http://localhost:8080/JSLib/jquery-1.11.1.js:3443:13)
在HTMLDocument.completed(http://localhost:8080/JSLib/jquery-1.11.1.js:3474:10):保存已注册
此外,我还使用了这些图书馆:
- jquery-1.11.1
- 下划线min(最新)
- 主干网(最新版本)
- 引导程序3
- 西农1.10.2
- qunit 1.14.0
抛出的第一个参数必须是回调,而不是方法调用本身,请尝试以下操作:
throws(function() { mainView.registerSave(mockCreator2);}, 'also throws an error')